<%@page import="com.sq.partner.manager.util.StrUtil"%>
<%@page import="java.sql.Struct"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://" + request.getServerName() + ":" + request.getServerPort() + path+ "/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<base href="<%=basePath%>">
<title>方案审核</title>
<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
<script src="js/jquery.validate.js" type="text/javascript" ></script>
<script src="js/jquery.divbox.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>
	<script src="js/nlifePlanConfig.js" type="text/javascript"></script>

<style type="text/css">
	.input_text{width:180px;}
	.select_1{width:180px;}
	#agentInfoRela3Table{
		 margin: auto;
	}
	#agentInfoRela4Table{
		 margin: auto;
	}
	#agentInfoRela3Table td{
		border: 1px solid #bbcddb;
		height:15px; 
		line-height:15px;
	}
	#agentInfoRela4Table td{
		border: 1px solid #bbcddb;
		height:15px; 
		line-height:15px;
	}
	#agentInfoRela6Table td{
	   text-align: center;
	}
	#agentInfoRela5Table td{
		text-align: center;
	}
</style>

</head>

<script type="text/javascript">
	//自定义map功能
	function Map(){
	  this.elements = new Array();
	   //获取MAP元素个数
	   this.size = function() {
	       return this.elements.length;
	   };
	   //判断MAP是否为空
	   this.isEmpty = function() {
	       return (this.elements.length < 1);
	   };
	   //删除MAP所有元素
	   this.clear = function() {
	       this.elements = new Array();
	   };
	   //向MAP中增加元素（key, value)
	   this.put = function(_key, _value) {
	       if(this.containsKey(_key)){
	        this.remove(_key);
	        this.elements.push( {
	           key : _key,
	           value : _value
	        });
	       }else{
	        this.elements.push( {
	           key : _key,
	           value : _value
	        });
	       }  
	   };
	   //删除指定KEY的元素，成功返回True，失败返回False
	   this.remove = function(_key) {
	       var bln = false;
	       try {
	           for (var i = 0; i < this.elements.length; i++) {
	               if (this.elements[i].key == _key) {
	                   this.elements.splice(i, 1);
	                   return true;
	               }
	           }
	       } catch (e) {
	           bln = false;
	       }
	       return bln;
	   };
	   //获取指定KEY的元素值VALUE，失败返回NULL
	   this.get = function(_key) {
	       try {
	           for (var i = 0; i < this.elements.length; i++) {
	               if (this.elements[i].key == _key) {
	                   return this.elements[i].value;
	               }
	           }
	       } catch (e) {
	           return false;
	       }
	       return false;
	   };
	   //判断MAP中是否含有指定KEY的元素
	   this.containsKey = function(_key) {
	       var bln = false;
	       try {
	           for (var i = 0; i < this.elements.length; i++) {
	               if (this.elements[i].key == _key) {
	                   bln = true;
	               }
	           }
	       } catch (e) {
	           bln = false;
	       }
	       return bln;
	   };
	  //获取map的所有values
	  this.values = function() {
	       var arr = new Array();
	       for (var i = 0; i < this.elements.length; i++) {
	           arr.push(this.elements[i].value);
	       }
	       return arr;
	   };
	  //获取map的所有keys
	  this.keys= function() {
	       var arr = new Array();
	       for (var i = 0; i < this.elements.length; i++) {
	           arr.push(this.elements[i].key);
	       }
	       return arr;
	   };
	   //获取数组
	   this.getArray= function(){
	   	var arr = new Array();
	   	for (var i = 0; i < this.elements.length; i++) {
	           arr.push({
		            key : this.elements[i].key,
		            value : this.elements[i].value
		         });
	       }
	       return arr;
	   };
	}
//********************************************	
	
	var map = new Map();
	var mapBak = new Map();
	var agentInfoList = new Array();
	
	var oldAgentType = '';//复制新增时的原agentType
	var oldPartnerNo='';//复制新增时的原partnerNo;
	$(function(){
		<c:choose>
			<c:when test="${not empty planNo || not empty oldPlanNo}">
				//编辑/复制新增 时，才需进行的初始化操作
				init();
			</c:when>
		</c:choose>
	});

	function init(){
		<c:choose>
			<c:when test="${not empty planNo}">
				$("#saveNlifePlanBtn").click(function(){
					checkAndExcute('update');
				});
				$("#saveNlifePlanBack").click(function(){
					checkAndExcute('update');
				});
			</c:when>
		</c:choose>
		
		var planNo = $.trim($('#hidePlanNo').val());
		$("tr[id^=agentType1]").css('display','none');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','none');
		$("tr[id^=agentType5]").css('display','none');
		$("tr[id^=agentType6]").css('display','none');
		$.ajax({
			url : "<%=path%>/nlifePlanCheck/loadNlifePlanCheck?"+new Date().getTime(),
			type : 'POST',
			async : false,
			data:{planNo:planNo},
			dataType:'json',
			success:function(data){
				if($.validate(data))return;
				
				var nlifePlan = data.nlifePlan;
				var nlifeProd = data.nlifeProd;
				var nlifeCoreProd = data.nlifeCoreProd;
				oldAgentType = nlifePlan.agentType;
				oldPartnerNo = nlifePlan.partnerNo;
				$("#agentType").val(nlifePlan.agentType);
				$('#planNo').val(nlifePlan.planNo);
				$('#planName').val(nlifePlan.planName);
				$('#prodCode').val(nlifePlan.prodCode);
				$('#prodSaleCode').val(nlifeCoreProd.prodSaleCode);
				$('#partnerNo').val(nlifePlan.partnerNo);
				//加载方案名称与方案号
				document.getElementById("unionMessageConfigPlanNoTitle").innerHTML += nlifePlan.planNo;
				document.getElementById("unionMessageConfigPlanNameTitle").innerHTML += nlifePlan.planName;
				$('#newBsnsType').val(nlifePlan.newBsnsType);
				$('#bsnsType').val(nlifePlan.categoryCode);
				$('#channleCode_QD').val(nlifePlan.channleCode);
				$('#channleType').val(nlifePlan.channleType);
				$('#applicant_no').val(nlifePlan.applicantNo);	
				$('#marketPreserveRate').val(nlifePlan.marketPreserveRate);
				$('#businessPerformanceRate').val(nlifePlan.businessPerformanceRate);
				$('#checkOpinion').val(nlifePlan.checkOpinion);
				
				//是否电子保单
				$("#iseplicyFlag").val(nlifeProd.epolicyCode+'-'+nlifeProd.epolicyName);
				
				//续保费用比例差值
				$("#rateSubtract").val(nlifePlan.rateSubtract);
				$('#propTitle').html("电子保单模板："+nlifeProd.epolicyCode+'-'+nlifeProd.epolicyName)
				if("19002"!=nlifePlan.categoryCode && "19003"!=nlifePlan.categoryCode){
					$("#agentNo").val("");
					$('#agentNo').attr("disabled",true);
					$("#agentNo").css({"background-color": "#ccc"});
					$("#agentName").val("");
					$('#agentName').attr("disabled",true);
					$("#agentName").css({"background-color": "#ccc"});
					$("#protocolNo").val("");
					$('#protocolNo').attr("disabled",true);
					$("#protocolNo").css({"background-color": "#ccc"});
					$("#agentNo ~ span").remove(".red");
					$("#agentName ~ span").remove(".red");
					$("#protocolNo ~ span").remove(".red");
				}
				
				$('#commRate').val(nlifePlan.commRate);
				// 3、个人代理4、总对总代理5、联合出单代理 1、合作伙伴代理
				if("3"==nlifePlan.agentType){
					$("#cardApplicant_div").css('display','none');
					$("#cardApplicant_div_cue").css('display','none');
					$("#cardApplicant_title").css('display','none');
					queryAgentInfoRela3(1);
					mapBak.clear();//清空备份map
					
					var agentInfoList = data.agentInfoList;
					for(var i in agentInfoList){  
			        	var obj = new Object();
			        	obj.id = agentInfoList[i].ID;
			        	obj.cardapplicant = agentInfoList[i].CARDAPPLICANT==null?"":agentInfoList[i].CARDAPPLICANT;
			        	obj.commrate = agentInfoList[i].COMMRATE==null?"":agentInfoList[i].COMMRATE;
			        	obj.business=agentInfoList[i].BUSINESS==null?"":agentInfoList[i].BUSINESS;
			        	obj.market=agentInfoList[i].MARKET==null?"":agentInfoList[i].MARKET;
			        	map.put(obj.id,obj);
			        	mapBak.put(obj.id,obj);
			      	}
					
					$("tr[id^=quDao0]").css('display','none');
					$("tr[id^=agentType1]").css('display','none');
					$("tr[id^=agentType3]").css('display','');
					$("tr[id^=agentType4]").css('display','none');
					$("tr[id^=agentType5]").css('display','none');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode102").append("<input type='hidden' id='dptCde'/>");
				}else if("4"==nlifePlan.agentType){
					$("#cardApplicant_div").css('display','none');
					$("#cardApplicant_div_cue").css('display','none');
					$("#cardApplicant_title").css('display','none');
					queryAgentInfoRela4(1);
					mapBak.clear();//清空备份map
					
					var agentInfoList = data.agentInfoList;
					for(var i in agentInfoList){  
			        	var obj = new Object();
			        	obj.id = agentInfoList[i].ID;
			        	obj.cardapplicant = agentInfoList[i].CARDAPPLICANT==null?"":agentInfoList[i].CARDAPPLICANT;
			        	obj.commrate = agentInfoList[i].COMMRATE==null?"":agentInfoList[i].COMMRATE;
			        	obj.business=agentInfoList[i].BUSINESS==null?"":agentInfoList[i].BUSINESS;
			        	obj.market=agentInfoList[i].MARKET==null?"":agentInfoList[i].MARKET;
			        	map.put(obj.id,obj);
			        	mapBak.put(obj.id,obj);
			      	}
					
					$("tr[id^=quDao0]").css('display','none');
					$("tr[id^=agentType1]").css('display','none');
					$("tr[id^=agentType3]").css('display','none');
					$("tr[id^=agentType4]").css('display','');
					$("tr[id^=agentType5]").css('display','none');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode102").append("<input type='hidden' id='dptCde'/>");
				}else if("5"==nlifePlan.agentType){
					$("#unionType").val(nlifePlan.unionType);
					$("#unionType").show();
					isDisable("unionType", true);
					$("#cardApplicant_div").css('display','none');
					$("#cardApplicant_div_cue").css('display','none');
					$("#cardApplicant_title").css('display','none');
					queryAgentInfoRela5(1);
					mapBak.clear();//清空备份map
					var agentInfoList = data.agentInfoList;
					for(var i in agentInfoList){  
			        	var obj = new Object();
			        	obj.id = agentInfoList[i].ID;
			        	obj.cardapplicant = agentInfoList[i].CARDAPPLICANT==null?"":agentInfoList[i].CARDAPPLICANT;
			        	obj.commrate = agentInfoList[i].COMMRATE==null?"":agentInfoList[i].COMMRATE;
			        	obj.business=agentInfoList[i].BUSINESS==null?"":agentInfoList[i].BUSINESS;
			        	obj.market=agentInfoList[i].MARKET==null?"":agentInfoList[i].MARKET;
			        	map.put(obj.id,obj);
			        	mapBak.put(obj.id,obj);
			      	}
					$("tr[id^=quDao0]").css('display','none');
					$("tr[id^=agentType1]").css('display','none');
					$("tr[id^=agentType3]").css('display','none');
					$("tr[id^=agentType4]").css('display','none');
					$("tr[id^=agentType5]").css('display','');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode102").append("<input type='hidden' id='dptCde'/>");
				}else if("6"==nlifePlan.agentType){
					$("tr[id^=agentType1]").css('display','');
					$("tr[id^=agentType3]").css('display','none');
					$("tr[id^=agentType4]").css('display','none');
					$("tr[id^=agentType5]").css('display','none');
					$("tr[id^=agentType6]").css('display','none');
					$('#empNo').val(nlifePlan.empNo);
					$('#empName').val(nlifePlan.empName);
					$('#teamCode').val(nlifePlan.teamCode);
					$('#teamName').val(nlifePlan.teamName);
					$('#agentNo').val(nlifePlan.agentNo);
					$('#agentName').val(nlifePlan.agentName);
					$('#protocolNo').val(nlifePlan.protocolNo);
					$('#serviceCode').val(nlifePlan.serviceCode);
					$('#serviceName').val(nlifePlan.serviceName);
					$("tr[id^=quDao0]").css('display','');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode101").append("出单机构：");
					$("#deptCode102").append("<input id='dptCde' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;&nbsp;<input type='button' class='input_button_2' value='请选择' onClick='openDeptDiv()' />");
					$('#dptCde').val(nlifePlan.dptCde);
					$('#agentFeeConfig').val(nlifePlan.agentFeeConfig);
					if(nlifePlan.agentFeeConfig!=null&&nlifePlan.agentFeeConfig!=''){
						agentFeeConfigChange();
					}
					if(nlifePlan.agentFeeConfig=='2'){
						$("tr[id^=agentType6]").css('display','');
						queryAgentInfoRela6(1);
					}
				}else{
					$('#empNo').val(nlifePlan.empNo);
					$('#empName').val(nlifePlan.empName);
					$('#teamCode').val(nlifePlan.teamCode);
					$('#teamName').val(nlifePlan.teamName);
					$('#agentNo').val(nlifePlan.agentNo);
					$('#agentName').val(nlifePlan.agentName);
					$('#protocolNo').val(nlifePlan.protocolNo);
					$('#serviceCode').val(nlifePlan.serviceCode);
					$('#serviceName').val(nlifePlan.serviceName);
					
					$("tr[id^=quDao0]").css('display','');
					$("tr[id^=agentType1]").css('display','');
					$("tr[id^=agentType3]").css('display','none');
					$("tr[id^=agentType4]").css('display','none');
					$("tr[id^=agentType5]").css('display','none');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode101").append("出单机构：");
					$("#deptCode102").append("<input id='dptCde' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;&nbsp;<input type='button' class='input_button_2' value='请选择' onClick='openDeptDiv()' />");
					$('#dptCde').val(nlifePlan.dptCde);
				}
				console.log(nlifePlan.agentType);
				if("7"==nlifePlan.agentType){
					$('#cRate').html('手续费比例上限：');
					$('#mRate').html('市场维护费比例上限：');
					$('#bRate').html('业务绩效比例上限：');
					$("tr[id^=quDao0]").css('display','none');
				}
				//短信模板、短信接收人动态显示
				$('#isMessage').val(nlifePlan.isMessage);
				if(nlifePlan.isMessage=='Y'){
					$('#messageTemplateTr').show();
					$('#messageTemplate').css("background-color","white");
					$('#messageTemplate').val(data.messageTemplate_val);
					$('#messageReceiverDiv').show();
					$('#smsTemplateDiv').show();
					$('#smsTemplate').val(nlifePlan.messageTemplate);
					console.log(nlifePlan.messageTemplate);
					$('#messageReceiver').val(nlifePlan.messageReceiver);
				}
				
				//注销短信模板、短信接收人动态显示
				$('#isCancelMessage').val(nlifePlan.isCancelMessage);
				if(nlifePlan.isCancelMessage=='Y'){
					$('#cancelTemplateTr').show();
					$('#cancelTemplate').css("background-color","white");
					$('#cancelTemplate').val(data.cancelTemplate_val);
					$('#cancelReceiverDiv').show();
					$('#cancelTemplateDiv').show();
					$('#isCancelTemplate').val(nlifePlan.cancelTemplate);
					console.log(nlifePlan.cancelTemplate);
					$('#cancelReceiver').val(nlifePlan.cancelReceiver);
				}
				//是否回执动态显示
				$('#isReceipt').val(nlifePlan.isReceipt);
				if(nlifePlan.isReceipt=='Y'){
					$('#isOrNotDisplayReceiptTypeDiv').show();
					$('#receiptType').val(nlifePlan.receiptType);
				}
				//是否分期动态显示
				$('#isPayment').val(nlifePlan.isPayment);
				if(nlifePlan.isPayment=='Y'){
					$('#isOrNotDisplayPaymentTypeDiv').show();
					$('#paymentType').val(nlifePlan.paymentType);
				}
				$('#state').val(nlifePlan.state);
				$('#specialArran').val(nlifePlan.specialArran);
				$('#isSeeMoney').val(nlifePlan.isSeeMoney);
				if(nlifePlan.isSeeMoney=='YD'){
					$("#notice_1").show();
				}
				$('#isEpolicy').val(nlifePlan.isEpolicy);
				$('#notice').val(nlifePlan.notice);
				$('#checkStatus').val(nlifePlan.checkStatus);
				$('#isAddedService').val(nlifePlan.isAddedService);
				$('#addedServiceCode').val(nlifePlan.addedServiceCode);
				$('#addedServiceName').val(nlifePlan.addedServiceName);
				$('#addedServiceCount').val(nlifePlan.addedServiceCount);
				$('#mfacadeIsReInsure').val(nlifePlan.mfacadeIsReInsure);
				$('#isPushedSalesInfo').val(nlifePlan.isPushedSalesInfo);
				if(nlifePlan.isSeeMoney== "N"){
				//	$('#isDredgePay').attr("disabled",true);
					//$("#isDredgePay").css({"background-color": "#ccc"});
				}else{
					//$("#isDredgePay").attr("disabled",false);
					//$("#isDredgePay").css({"background-color": ""});
				}
				
				if("19002"!=nlifePlan.categoryCode&&"19003"!=nlifePlan.categoryCode){
// 					$("#agentNo ~ span").remove(".red");
					$("#agentNo").val("");
					$('#agentNo').attr("disabled",true);
					$("#agentNo").css({"background-color": "#ccc"});
					$("#agentName ~ span").remove(".red");
					$("#agentName").val("");
					$('#agentName').attr("disabled",true);
					$("#agentName").css({"background-color": "#ccc"});
					$("#protocolNo").val("");
					$('#protocolNo').attr("disabled",true);
					$("#protocolNo").css({"background-color": "#ccc"});
					$("#protocolNo ~ span").remove(".red");
					$("#agentNoButtonHidden").html("&nbsp;&nbsp;<input type='button'  class='input_button_2 red' id='queryAgentAndAgreeInfoBtn' value='获取' onClick='queryAgentAndAgreeInfo()'/>");
				}else{
					$("#agentNoButtonHidden").html("<span class='red' style='margin-left: -5px'>*</span>&nbsp; <input type='button'  class='input_button_2 red' id='queryAgentAndAgreeInfoBtn' value='获取' onClick='queryAgentAndAgreeInfo()'/>");
				}
				
				if(nlifePlan.isPayPlatform==''||nlifePlan.isPayPlatform==null){
					//$('#isDredgePay').val(1);
				}else{
					//$('#isDredgePay').val(nlifePlan.isPayPlatform);
				}
				
				if(nlifePlan.isEinvoice==''||nlifePlan.isEinvoice==null){
					$('#isEpolicyInvoice').val(2);
				}else{
					$('#isEpolicyInvoice').val(nlifePlan.isEinvoice);
				}
				var isEinvoice=$('#isEpolicyInvoice').val();
				if("1"==isEinvoice){
					$(".CinvockLink").show();
					$("#invockLink").val(nlifePlan.invockLink);
					$("#isInsuranceEinvoice").val(nlifePlan.isInsuranceEinvoice);
					$("#payEinvoice").val(nlifePlan.payEinvoice);
					isInsurEinvoiceChange();
					$("#einvoiceInfo").show();
				}else{
					$(".CinvockLink").hide();
				}
				$("#dentification").val(nlifePlan.dentification);

				//是不是发送邮件
				if(nlifePlan.isSendEmail==''||nlifePlan.isSendEmail==null){
					$('#isEpolicyMali').val(2);
				}else{
					$('#isEpolicyMali').val(nlifePlan.isSendEmail);
				}
				if((nlifePlan.isSendEmail)==0||(nlifePlan.isSendEmail)==2){
					$('#MailTemplateTr').hide();
				/* 	$('#sendAccessory').hide();
					$('#sendAccessoryTd').hide(); */
				}
				if((nlifePlan.isSendEmail)=="1"){
					$('#sendAccessory').show();
					$('#sendAccessoryTd').show();
					$('#MailTemplateTr').show();
					$('#MailTemplate').val(nlifePlan.emailTemplate);
					var ids=new Array(5);
					ids=data.ids;
					if(ids!=null){
						$('input[name=SendAccessoryBox]').each(function(){
							for(i=0;i<ids.length;i++){
								if($(this).val()==ids[i]){
									$(this).attr("checked",true);
								}
							}
						});
					}
				}
				//是不是发送电子保单
				if((nlifePlan.isEpolicy)=="Y"){
					$('#Download_left').val(nlifePlan.ISEPOLICY);
					$('#Download_right').show();
					$('#DownloadWay').show();
				}else{
					//rt(12312)
					$('#Download_left').val(nlifePlan.ISEPOLICY);
					$('#Download_right').hide();
				}
				$('#DownloadWay').val(nlifePlan.epolicyDownloadWay);
				downloadWayChange();
				$('#fileType').val(nlifePlan.fileType);
				$('#isPrintCard').val(nlifePlan.isPrintCard);
				if(nlifePlan.isPrintCard=='Y'){
					$('#cardApplicant').attr("readonly",false);
					$('#cardApplicant').css("background-color","white");
					$('#cardApplicant').val(nlifePlan.cardApplicant);
					$('#cardType').attr("readonly",false);
					$('#cardType').css("background-color","white");
					$('#cardType').val(nlifePlan.cardType);
				}
				//广东人员配置信息
				var sale=$('#dptCde').val().substring(0,2);
				if(sale=='44'){
					salemap.clear();
					$('#sale1').show();
					$('#sale2').show();
						//加载销售人员配置信息
					    var arr=data.sales;
						if(arr!=undefined&&arr.length>0){
							for (var i = 0; i < arr.length; i++) {
								var o=new Object();
								 o.seqNo=arr[i].seqNo
								 o.saleType=arr[i].presonType
								 o.costRate=(parseFloat(arr[i].agentFee))
								 o.permitNo=arr[i].practiceNo
								 o.saleName=arr[i].saleName
								 o.agentCode=arr[i].agentCode;
								 o.agentName=arr[i].agentName;
								 o.salePerson=arr[i].empNo;
								 o.saleTypeName=arr[i].saleTypeName;
								salemap.put(arr[i].seqNo,o)
							}
							saleTable();
						}
				}else{
					$('#sale1').hide();
					$('#sale2').hide();
				}
				//争议解决方式
			    $("#dicputeType").val(nlifePlan.dicputeType);
				if(nlifePlan.dicputeType!=2){
					$("#arbitrationDept").hide();
				}else{
					$("#arbitrationDept").val(nlifePlan.arbitrationDept);
				}
				
				//争议解决方式结束
				//是否风险查询
				$('#isRiskQuery').val(nlifePlan.isRiskQuery);
			}
		});
 //加载投保方案审核配置界面只有“审核意见”字段的内容是可写的，其他内容均为只读形式。
		$('input').attr("disabled",true);
		$('input').css("background-color","#ccc");
		$('select').attr("disabled",true);
		$('select').css("background-color","#ccc");
		$('textarea').attr("disabled",true);
		$('textarea').css("background-color","#ccc");
		$('#checkOpinion').attr("disabled",false);
		$('#checkOpinion').css("background-color","");  
		$('#saveNlifePlanBtn').attr("disabled",false);
		$('#saveNlifePlanBtn').css("background-color",""); 
		$('#saveNlifePlanBack').attr("disabled",false);
		$('#saveNlifePlanBack').css("background-color","");
		$('#unionMessageConfig').attr("disabled",false);
		$('#unionMessageConfig').css("background-color","");
		$('#unionMessageConfigDept').attr("disabled",false);
		$('#unionMessageConfigDept').css("background-color","");
	}
	var salemap=new Map();
	/**是否可以录入*/
	function isDisable (obj,flag){
		//可用
		if(!flag){
			$("#"+obj).attr("disabled",false);
			$("#"+obj).css({"background-color": ""});
		}else{
			//不可用
			$("#"+obj).attr("disabled",true);
			$("#"+obj).css({"background-color": "#ccc"});
		}
	}
	function isInsurEinvoiceChange(){
		var isInsuranceEinvoice=$("#isInsuranceEinvoice").val();
		/* var payEinvoice=$("#payEinvoice").val(); */
		if(isInsuranceEinvoice=='Y'){
			$("#payEinvoice").val('1');
			$('#payEinvoice').attr("disabled",true);
			$('#payEinvoice').css("background-color","#ccc");
		}else{
			$('#payEinvoice').attr("disabled",false);
			$('#payEinvoice').css("background-color","");
		}
	}
	//下载方式改变方式
	function downloadWayChange(){
		var flag=$('#DownloadWay').val();
		if(flag=='1'){
			$('#fileTypeSpan').show()
		}else{
			$('#fileTypeSpan').hide()
		}
		
	}
	//销售人员table
	function saleTable(){
		$('#saleShowDiv').html('');
		var ht='';
		for (var i = 1; i <=5; i++) {
			var o=salemap.get(i);
			if(o.agentCode==undefined){
				o.agentCode='';
			}
			if(o.agentName==undefined){
				o.agentName='';
			}
			if(o.permitNo==undefined){
				o.permitNo=''
			}
			if(o.saleName==undefined){
				o.saleName='';
			}
			if(o){
				ht+='<tr>'+
				'<td style="width:100px;text-align: center;">'+o.seqNo+'</td>'+
				'<td style="width:100px;text-align: center;">'+o.saleTypeName+'</td>'+
				'<td style="width:100px;text-align: center;">'+o.salePerson+'</td>'+
				'<td style="width:100px;text-align: center;">'+o.saleName+'</td>'+
				'<td style="width:100px;text-align: center;">'+o.permitNo+'</td>'+
				'<td style="width:100px;text-align: center;">'+o.agentCode+'</td>'+
				'<td style="width:100px;text-align: center;">'+o.agentName+'</td>'+
				'<td style="width:100px;text-align: center;">'+parseFloat(o.costRate).toFixed(2)+'</td>'
			}
		}
		$('#saleShowDiv').html(ht);
	}
	//“归属渠道”改变时
	function changeChannleCode_QD(){
		var channleCode_QD = $.trim($("#channleCode_QD").val());
		loadSubCascadeList("channel_type",channleCode_QD,"channleType");
		loadSubCascadeList("new_business_source","","newBsnsType");
		
		agentInfoWrite();
		serviceInfoWrite();
	}
	/**跟单费用配置改变**/
	function agentFeeConfigChange(){
		var agentFeeConfig =$('#agentFeeConfig').val();
		/**接口传入*/
		if('1'==agentFeeConfig){
			$('#cRate').html('手续费比例上限：');
			$('#mRate').html('市场维护费比例上限：');
			$('#bRate').html('业务绩效比例上限：');	
			$("tr[id^=quDao0]").css('display','none');
		}else{
			$('#cRate').html('手续费比例：');
			$('#mRate').html('市场维护费比例：');
			$('#bRate').html('业务绩效比例：');
		
		}
	}
	//加载接口传入(agentType==6)代理信息前，拼接参数
	function queryAgentInfoRela6(pageIndex){
		var size = 5;
		var planNo = $.trim($('#planNo').val());
		var agentType ="6";
		loadAgentInfoRela6({size:size,current:pageIndex,planNo:planNo,agentType:agentType});
	}
	/**已配置的维度信息*/
	var tdate="";
	var title="";
	function createTable(weids){
		var weidl=weids.split(",");
		tdate="";
		title="";
		for (var i = 0; i < weidl.length; i++) {
			if(weidl[i]==0){
				title='<th style="text-align: center;">机构</th>';
				tdate="branch,"
			}else if(weidl[i]==1){
				title+='<th style="text-align: center;">业务来源</th>';
				tdate+="nchannelSource,"
			}else if(weidl[i]==2){
				title+='<th style="text-align: center;">产品大类</th>';
				tdate+="nproductType,"
			}else if(weidl[i]==3){
				title+='<th style="text-align: center;">代理人代码/业务员代码</th>';
				tdate+="empNo,"
			}
		}
		title+='<th style="text-align: center;">手续费比例（%）</th><th style="text-align: center;">市场维护费比例（%）</th><th style="text-align: center;">业务绩效比例（%）</th>';
		tdate+='commRate,marketRate,businessRate';
	}
	//加载已配置的三费信息
	function loadAgentInfoRela6(param){
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoRelaPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if(page.data&&page.data.length>0){
					if ($("#agentFeeConfig").val() == "2"){
						$('#agentNameTitle').html(page.data[0].agentNo + "-" + page.data[0].agentName);
					}else {
						$('#agentNameTitle').html(page.data[0].agentName);
					}
					if(param.current=='1'){
						createTable(page.data[0].weidConfig);
					}
					$("#agentFeeTitle").html(title)
				}
				// var fieldNames="branch,nproductType,commRate,businessRate,marketRate";
				var fieldNames=tdate;
				var tableContent = creatTable1(fieldNames,page);
				var tableObj = $("#agentInfoRela6Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage3(param.current,6,page.maxPage,"64");
				var pageDIV = $("#agentInfoRela6PageDIV");
				pageDIV.html('');
				pageDIV.append(strPage);
			}
		});
	}//加载已配置的三费信息结束
	//"渠道类型"改变时
	function changeChannleType(){
		var channleType = $.trim($("#channleType").val());
		loadSubCascadeList("new_business_source",channleType,"newBsnsType");
		
		agentInfoWrite();
		serviceInfoWrite();
	}
	
	//"业务来源"改变时
	function changeNewBsnsType(){
		var parentCode = $("#channleType").val();
		var newBsnsCode = $("#newBsnsType").val();
 		agentInfoWrite();
		serviceInfoWrite(); 
		chooseBsnsType(parentCode,newBsnsCode);
	}
	//点击"请选择(产品)" 弹出产品选择层
	function openNlifeProdDiv(){
		//加载第一页产品信息
		queryNlifeProd(1);
	}
	//加载产品信息前，拼接参数
	function queryNlifeProd(pageIndex){
		var size = 8;
		var prodCode = $.trim($('#prodCode_choose').val());
		var prodName = $.trim($('#prodName_choose').val());
		var DateReg = /^(\d{4})\-(\d{2})\-(\d{2})$/;
		var startDateBegin = $.trim($('#startDateBegin').val());
		var startDateEnd = $.trim($('#startDateEnd').val());
		var sflag = DateReg.test(startDateBegin);
		var eflag = DateReg.test(startDateEnd);
		if(null != startDateBegin && "" != startDateBegin){
			if(!sflag){
				$.message("error", "您输入的定义起期格式不正确，格式为：YYYY-MM-DD。请重新选择日期");
				$('#startDateBegin').val('');
				return;
			}
		}
		if(null != startDateEnd && "" != startDateEnd){
			if(!eflag){
				$.message("error", "您输入的定义止期格式不正确，格式为：YYYY-MM-DD。请重新选择日期");
				$('#startDateEnd').val('');
				return;
			}
		}
		loadNlifeProd({size:size,current:pageIndex,prodCode:prodCode,prodName:prodName,startDateBegin:startDateBegin,startDateEnd:startDateEnd});
	}
	
	//根据传入的参数，加载相应的产品
	function loadNlifeProd(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryNlifeProdPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;

				var radioObj ="<input class='input_fxk' name='radioNlifeProd' type='radio'/>";
				var fieldNames = "PROD_CODE,PROD_NAME,AGENT_TYPE@TDH,PROD_SALE_CODE@TDH";
				var tableContent = creatTable1(fieldNames,page,radioObj);
				var tableObj = $("#nlifeProdTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage(param.current,6,page.maxPage,"43");
				var pageDIV = $("#nlifeProdPageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
				$("#nlifeProdDiv").OpenDiv();

				bindradio();
			}
		});
	}
	
	//点击“确定”按钮，选择产品
	function chooseNlifeProd(){
		var selected = $("input[name='radioNlifeProd']:checked");
		if(selected.length==0){
			$.message("error", "请选择一个产品");
			return;
		}
		
		var prodCode_current = $.trim($('#prodCode').val());
		
		var prodCode = selected.parent().parent().children(" td:eq(1)").html();
		$('#prodCode').val(prodCode);
		var prodSaleCode = selected.parent().parent().children(" td:eq(4)").html();
		$('#prodSaleCode').val(prodSaleCode);//该值是为了向销管获取代理信息时传参
		
		var agentType = selected.parent().parent().children(" td:eq(3)").html();
		$("#agentType").val(agentType);
		
		if(prodCode != prodCode_current){//如果产品更换
			agentInfoWrite();
		}
		
		//1、合作伙伴代理3、个人代理4、总对总代理
		if('1'==agentType){
			$("#cardApplicant_div").css('display','');
			$("#cardApplicant_div_cue").css('display','');
			$("#cardApplicant_title").css('display','');
			$("tr[id^=quDao0]").css('display','');
			$("tr[id^=agentType1]").css('display','');
			$("tr[id^=agentType3]").css('display','none');
			$("tr[id^=agentType4]").css('display','none');
			$("#commRateSpan").empty();
			$("#deptCode101").empty();
			$("#deptCode102").empty();
			$("#deptCode101").append("出单机构：");
			$("#deptCode102").append("<input id='dptCde' readonly='readonly' style='background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;&nbsp;<input type='button'  class='input_button_2' value='请选择' onClick='openDeptDiv()' />");
		}else if('3'==agentType){
			$("#cardApplicant_div").css('display','none');
			$("tr[id^=quDao0]").css('display','none');
			$("tr[id^=agentType1]").css('display','none');
			$("tr[id^=agentType3]").css('display','');
			$("tr[id^=agentType4]").css('display','none');
			$("#commRateSpan").html("销售业务信息未配置,则使用此比例");
			$("#deptCode101").empty();
			$("#deptCode102").empty();
			$("#deptCode102").append("<input type='hidden' id='dptCde' />");
		}else if('4'==agentType){
			$("#cardApplicant_div").css('display','none');
			$("tr[id^=quDao0]").css('display','none');
			$("tr[id^=agentType1]").css('display','none');
			$("tr[id^=agentType3]").css('display','none');
			$("tr[id^=agentType4]").css('display','');
			$("#commRateSpan").html("销售业务信息未配置,则使用此比例");
			$("#deptCode101").empty();
			$("#deptCode102").empty();
			$("#deptCode102").append("<input type='hidden' id='dptCde' />");
		}else{
			$("#cardApplicant_div").css('display','none');
			$("tr[id^=quDao0]").css('display','none');
			$("tr[id^=agentType1]").css('display','');
			$("tr[id^=agentType3]").css('display','none');
			$("tr[id^=agentType4]").css('display','none');
			$("#commRateSpan").empty();
			$("#deptCode101").empty();
			$("#deptCode102").empty();
			$("#deptCode101").append("出单机构：");
			$("#deptCode102").append("<input id='dptCde' readonly='readonly' style='background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;&nbsp;<input type='button'  class='input_button_2' value='请选择' onClick='openDeptDiv()' />");
		}
		
		closeNlifeProdDiv();
		//清空出单机构
		$("#dptCde").val("");
	}
	
	//关闭 选择产品 弹出层
	function closeNlifeProdDiv(){
		$("#nlifeProdDiv").CloseDiv();	
		
		$('#prodCode_choose').val("");
		$('#prodName_choose').val("");
		$('#startDateBegin').val("");
		$('#startDateEnd').val("");
	}
	
	//点击"请选择(合作伙伴)" 弹出合作伙伴选择层
	function openChannelInfoDiv(){
		//必须先选择产品，在选择合作伙伴
		if(($.trim($('#prodCode').val())).length==0){
			$.message('error',"请先选择产品");
			return;
		}	
		//加载第一页合作伙伴信息
		queryChannelInfo(1);
	}
	
	//加载合作伙伴信息前，拼接参数
	function queryChannelInfo(pageIndex){
		var size = 8;
		var channelCode = $.trim($('#channelCode_choose').val());
		var channelName = $.trim($('#channelName_choose').val());
		
		loadChannelInfo({size:size,current:pageIndex,channelCode:channelCode,channelName:channelName});
	}
	
	//根据传入的参数，加载相应的合作伙伴
	function loadChannelInfo(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryChannelInfoPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;
	
				var radioObj ="<input class='input_fxk' name='radioChannelInfo' type='radio' value=''>";
				var fieldNames = "channelCode,channelName";
				var tableContent = creatTable1(fieldNames,page,radioObj);
				var tableObj = $("#channelInfoTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage2(param.current,6,page.maxPage,"42");
				var pageDIV = $("#channelInfoPageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
				$('#channelInfoDiv').OpenDiv();
				
				bindradio();
			}
		});
	}
	
	//点击“确定”按钮，选择合作伙伴
	function chooseChannelInfo(){
		var partnerNo = $.trim($("#partnerNo").val());
		
		var selected = $("input[name='radioChannelInfo']:checked");
		if(selected.length==0){
			$.message("error", "请选择一个合作伙伴");
			return;
		}
		var channelCode = selected.parent().parent().children("td:eq(1)").html();
		$('#partnerNo').val(channelCode);
		
		//合作伙伴 改变，同步改变 出单机构等
		if(partnerNo != channelCode){
			$('#dptCde').val('');
			
			//代理信息
			$("#agentInfoRela3Table").find("tbody").remove();
			$("#agentInfoRela3PageDIV")[0].innerHTML="";
			$("#agentInfoRela4Table").find("tbody").remove();
			$("#agentInfoRela4PageDIV")[0].innerHTML="";
			
			empInfoWrite();
			teamInfoWrite();
			agentInfoWrite();
			serviceInfoWrite();
		}
		
		closeChannelInfoDiv();
		//清空出单机构
		$("#dptCde").val("");
	}
	
	//关闭 选择合作伙伴 弹出层
	function closeChannelInfoDiv(){
		$("#channelInfoDiv").CloseDiv();	

		$('#channelCode_choose').val("");
		$('#channelName_choose').val("");
	}
	
	//点击"请选择(出单机构)" 弹出出单机构选择层
	function openDeptDiv(){
		//必须先选择合作伙伴，在选择出单机构
		if(($.trim($('#partnerNo').val())).length==0){
			$.message('error',"请先选择合作伙伴代码");
			return;
		}
		
		//加载第一页出单机构
		queryDept(1);
	}
	
	//加载出单机构信息前，拼接参数
	function queryDept(pageIndex){
		var size = 8;
		var partnerNo = $.trim($('#partnerNo').val());
		var deptCode = $.trim($('#deptCode_choose').val());
		var deptCname = $.trim($('#deptCname_choose').val());
		
		loadDept({size:size,current:pageIndex,deptCode:deptCode,deptCname:deptCname,partnerNo:partnerNo});
	}
	
	//根据传入的参数，加载相应的出单机构
	function loadDept(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryDeptPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;
	
				var radioObj ="<input class='input_fxk' name='radioDept' type='radio'/>";
				var fieldNames = "deptCode,deptCNname";
				var tableContent = creatTable1(fieldNames,page,radioObj);
				var tableObj = $("#deptTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage3(param.current,6,page.maxPage,"44");
				var pageDIV = $("#deptPageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				$('#deptDiv').OpenDiv();
				
				bindradio();
			}
		});
	}
	
	//点击“确定”按钮，选择出单机构
	function chooseDept(){
		var dptCde_current = $.trim($('#dptCde').val());
		
		var selected = $("input[name='radioDept']:checked");
		if(selected.length==0){
			$.message("error", "请选择一个出单机构");
			return;
		}
		var dptCde = selected.parent().parent().children(" td:eq(1)").html();
		$('#dptCde').val(dptCde);
		
		//出单机构 改变时，关联信息同步改变
		if(dptCde_current != dptCde){
			empInfoWrite();
			teamInfoWrite();
			agentInfoWrite();
			serviceInfoWrite();
		}
		
		closeDeptDiv();
	}
	
	//关闭 选择出单机构 弹出层
	function closeDeptDiv(){
		$("#deptDiv").CloseDiv();	

		$('#deptCode_choose').val("");
		$('#deptCname_choose').val("");
	}
	
	//绑定单选按钮事件，选中某个单选按钮，该按钮所在行高亮显示
	function bindradio(){
		$("input[name='radioNlifeProd']").click(function(){
			$("input[name='radioNlifeProd']").parent().parent().removeClass("table_highlighter");
			$(this).parent().parent().addClass("table_highlighter");
	   	});
		$("input[name='radioChannelInfo']").click(function(){
			$("input[name='radioChannelInfo']").parent().parent().removeClass("table_highlighter");
			$(this).parent().parent().addClass("table_highlighter");
	   	});
		$("input[name='radioDept']").click(function(){
			$("input[name='radioDept']").parent().parent().removeClass("table_highlighter");
			$(this).parent().parent().addClass("table_highlighter");
	   	});
		
		$("input[name='agentInfo3checkbox']").click(function(){
			var id= $(this).parent().parent().children("td:eq(1)").html();
			if($(this).prop("checked")){//选中
				$(this).parent().parent().addClass("table_highlighter");
				var obj = new Object();
				var cardApplicant= $(this).parent().parent().children("td:eq(7)").html();
				var commRate_Div= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.id =id;
				obj.cardapplicant = cardApplicant;
				obj.commrate= commRate_Div;
				map.put(obj.id,obj);
			}else{//取消选中
				$(this).parent().parent().removeClass("table_highlighter");
				$(this).prop("checked",false);
				map.remove(id);
			}
	   	});
		
		$("#agentInfo3CheckAll").click(function(){
			if($(this).prop("checked")){//选中
				$("#agentInfo3Table tbody tr").each(function() {
					$(this).find("input[name='agentInfo3checkbox']").prop("checked",true);
					$(this).addClass("table_highlighter");
					var obj = new Object();
					obj.id = $(this).children("td:eq(1)").html();
					obj.cardapplicant = $(this).children("td:eq(9)").html();
					obj.commrate = $(this).find("input[name='commRate_Div']").val();
					map.put(obj.id,obj);
				});
			}else{//取消选中
				$("#agentInfo3Table tbody tr").each(function() {
					$(this).removeClass("table_highlighter");
					$(this).find("input[name='agentInfo3checkbox']").prop("checked",false);
					var id= $(this).children("td:eq(1)").html();
					map.remove(id);
				});
			}
		});
		
		$("input[name='agentInfo4checkbox']").click(function(){
			var id= $(this).parent().parent().children("td:eq(1)").html();
			if($(this).prop("checked")){//选中
				$(this).parent().parent().addClass("table_highlighter");
				var obj = new Object();
				  var columnes=$("#agentInfo4Table").find("th").length;
				    if(columnes==17){
						obj.cardapplicant= $(this).parent().parent().children("td:eq(12)").html();
				    }else if(columnes==19){
						obj.cardapplicant= $(this).parent().parent().children("td:eq(14)").html();
				    }
				var commRate_Div= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.id =id;
				obj.cardapplicant = cardApplicant;
				obj.commrate= commRate_Div;
				map.put(obj.id,obj);
			}else{//取消选中
				$(this).parent().parent().removeClass("table_highlighter");
				$(this).prop("checked",false);
				map.remove(id);
			}
	   	});
		
		$("#agentInfo4CheckAll").click(function(){
			if($(this).prop("checked")){//选中
				$("#agentInfo4Table tbody tr").each(function() {
					$(this).find("input[name='agentInfo4checkbox']").prop("checked",true);
					$(this).addClass("table_highlighter");
					var obj = new Object();
					obj.id = $(this).children("td:eq(1)").html();
					  var columnes=$("#agentInfo4Table").find("th").length;
					    if(columnes==15){
							obj.cardapplicant = $(this).children("td:eq(10)").html();
					    }else if(columnes==17){
							obj.cardapplicant = $(this).children("td:eq(12)").html();
					    }
					obj.commrate = $(this).find("input[name='commRate_Div']").val();
					map.put(obj.id,obj);
				});
			}else{//取消选中
				$("#agentInfo4Table tbody tr").each(function() {
					$(this).removeClass("table_highlighter");
					$(this).find("input[name='agentInfo4checkbox']").prop("checked",false);
					var id= $(this).children("td:eq(1)").html();
					map.remove(id);
				});
			}
		});
	}
	
 	//获取业务员信息及业务员所在团队信息
 	var team_user_list;//存放销管返回的业务员及团队信息的List,便于业务员代码改变时，业务员名称和团队列表的同步改变
	function querySauserAndTeamInfo(){
 		var dptCde = $.trim($('#dptCde').val());
 		
		//必须先选择出单机构，再获取
		if(dptCde.length==0){
			$.message('error',"请先选择出单机构");
			return;
		}
 		
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/querySauserAndTeamInfo?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				COMCODE:dptCde
			},
			dataType:'json',
			success:function(result){
				$.closeLoading();
				if($.validate(result)){
					empInfoWrite();
					teamInfoWrite();
					agentInfoWrite();
					serviceInfoWrite();
					
					return;
				}
				
				var select = document.getElementById("empNo_select");
				select.options.length = 0;
				select.add(new Option("-----请选择-----",""));
				team_user_list = result.data;
				for (var i = 0; i < team_user_list.length; i++) {
					var option = new Option();
					option.text = team_user_list[i].USERCODE + "-" + team_user_list[i].USERNAME;
					option.title = team_user_list[i].USERCODE + "-" + team_user_list[i].USERNAME;
					option.value = team_user_list[i].USERCODE;
					select.add(option);
				}
				empInfoSelect();
			}
		});
	}
	//电子邮件改变时
	function CheckedSendMail(){
		var ChecdedMail=$("#isEpolicyMali").val();
		if(ChecdedMail==1){
			$("#MailTemplateTr").show();
			$('#MailTemplate').html("");
			$("#sendAccessory").show();
			$("#sendAccessoryTd").show();
			$('#SendAccessoryBox').show();
		}else{
		 	$("#MailTemplateTr").hide();
			/* $("#sendAccessory").hide(); 
			$("#sendAccessoryTd").hide(); */
		}
	}
	//是否回执
	function chooseReceiptType(){
		var value = $('#isReceipt').val();
		if('Y' == value){
			$('#isOrNotDisplayReceiptTypeDiv').show();
		}else if('N' == value){
			$('#isOrNotDisplayReceiptTypeDiv').hide();
			$('#receiptType').val('01');
		}
	}
	//是否分期
	function choosePaymentType(){
		var value = $('#isPayment').val();
		if('Y' == value){
			$('#isOrNotDisplayPaymentTypeDiv').show();
		}else if('N' == value){
			$('#isOrNotDisplayPaymentTypeDiv').hide();
			$('#paymentType').val('01');
		}
	}
	
	function CheckPassToList(){

		var state = $('#state').val();
 	    if('0' == state){
			$('#state').val('1');
		}
 	   var checkStatus = $('#checkStatus').val();
	    if(""==checkStatus||"未审核"==checkStatus||"退回"==checkStatus){
	    	$('#checkStatus').val('已审核');
	    } 
 	   
	}
	//是否电子保单
	function IsEpolicyChange(){
		var IsEpolicy =$.trim($('#isEpolicy').val());
		var Download_right=$('#Download_right');
		if(IsEpolicy=='Y'){
			Download_right.show();
		}else{
			Download_right.hide();
		}
	}
	//业务员代码可选状态
	function empInfoSelect(){
		$('#empNo_select_div').css('display','inline').val("");
		$('#empNo').hide().val('');
		
		$('#empName').attr("readonly",true).css('background-color','#ccc').val("");
	}
 	

	//业务员代码、业务员名称可输入状态
	function empInfoWrite(){
		$('#empNo_select_div').css('display','none').val("");
		$('#empNo').show().val('');
		
		$('#empName').attr("readonly",false).css('background-color','white').val('');
		
// 		$('#querySauserAndTeamInfoBtn').attr('disabled',true).removeClass("input_button_2");
// 		$('#queryAgentAndAgreeInfoBtn').attr('disabled',true).removeClass("input_button_2");
// 		$('#queryServiceNoBtn').attr('disabled',true).removeClass("input_button_2");
	}
 	
 	//业务员下拉框改变时，动态改变业务员名称和团队代码
 	var TEAMList;//存放当前所选业务员对应的团队List，便于团队代码改变时，团队名称的同步改变
 	function changeEmpNo(){
 		var empNo_select = $.trim($("#empNo_select").val());
 		$("#empNo").val(empNo_select);
 		
 		if(empNo_select.length==0) {
 			$("#empName").val("");
 			teamInfoWrite();
 			agentInfoWrite();
 			serviceInfoWrite();
 			return;
 		}	
 		
 		for (var i = 0; i < team_user_list.length; i++) {
			var USERCODE = team_user_list[i].USERCODE;
			if(empNo_select == USERCODE){
				$("#empName").val(team_user_list[i].USERNAME);
				
				TEAMList = team_user_list[i].TEAMList;
				var select = document.getElementById("teamCode_select");
				select.options.length = 0;
				select.add(new Option("-----请选择-----",""));
				for (var j = 0; j < TEAMList.length; j++) {
					var option = new Option();
					option.text = TEAMList[j].TEAMCODE + "-" + TEAMList[j].TEAMNAME;
					option.title = TEAMList[j].TEAMCODE + "-" + TEAMList[j].TEAMNAME;
					option.value = TEAMList[j].TEAMCODE;
					select.add(option);
				}
				teamInfoSelect();
				return;
			}
		}
 	}
 	
 	//团队代码改变时，动态改变团队名称
 	function changeTeamCode(){
 		var teamCode_select = $.trim($("#teamCode_select").val());
 		$("#teamCode").val(teamCode_select);
 		
 		if(teamCode_select.length==0) {
 			$("#teamName").val("");
 			agentInfoWrite();
 			serviceInfoWrite();
 			return;
 		}
 		
 		for (var i = 0; i < TEAMList.length; i++) {
 			var TEAMCODE = TEAMList[i].TEAMCODE;
 			if(teamCode_select == TEAMCODE){
 				$("#teamName").val(TEAMList[i].TEAMNAME);
 			}
 		}
 	}
 	
 	//团队代码可选状态
	function teamInfoSelect(){
		$('#teamCode_select_div').css('display','inline').val("");
		$('#teamCode').hide().val('');
		
		$('#teamName').attr("readonly",true).css('background-color','#ccc').val("");
	}
 	

	//团队代码、团队名称可输入状态
	function teamInfoWrite(){
		$('#teamCode_select_div').css('display','none').val("");
		$('#teamCode').show().val('');
		
		$('#teamName').attr("readonly",false).css('background-color','white').val('');
	}
 	
 	//查询中介-协议信息
 	var agent_agreement_list;//存放销管返回的代理人代码和协议号的List,便于代理人代码改变时，协议号的同步改变
	function queryAgentAndAgreeInfo(){
 		var prodSaleCode = $.trim($('#prodSaleCode').val());
 		var dptCde = $.trim($('#dptCde').val());
 		var channleCode_QD = $.trim($('#channleCode_QD').val());
 		var newBsnsType =$.trim($('#newBsnsType').val());
 		var teamCode = $.trim($('#teamCode').val());
		//必须先选择产品出单机构、归属渠道、业务来源，团队代码，再获取
		if(prodSaleCode.length==0){$.message('error',"请先选择产品");return;}
		if(dptCde.length==0){$.message('error',"请先选择出单机构");return;}
		if(channleCode_QD.length==0){$.message('error',"请先选择归属渠道");return;}
		if(newBsnsType.length==0){$.message('error',"请先选择业务来源");return;}
		if(teamCode.length==0){$.message('error',"请先选择团队代码");return;}

		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentAndAgreeInfo?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				COMCODE:dptCde,
				TEAMCODE:teamCode,
				BUSINESSSOURCE:newBsnsType,
				CHANNELNAME:channleCode_QD,
				PRODCODE:prodSaleCode
			},
			dataType:'json',
			success:function(result){
				$.closeLoading();
				if($.validate(result)) {
					agentInfoWrite();
					serviceInfoWrite();
					return;
				}
				
				var select = document.getElementById("agentNo_select");
				select.options.length = 0;
				select.add(new Option("-----请选择-----",""));
				agent_agreement_list = result.data;
				for (var i = 0; i < agent_agreement_list.length; i++) {
					var option = new Option();
					option.text = agent_agreement_list[i].AGENTCODE;
					option.title = agent_agreement_list[i].AGENTCODE;
					option.value = agent_agreement_list[i].AGENTCODE;
					select.add(option);
				}
				agentInfoSelect();
			}
		});
	}
 	
 	//代理人代码改变时，同步改变协议号
	function changeAgentNo(){
		var agentNo_select = $.trim($("#agentNo_select").val());
 		$("#agentNo").val(agentNo_select);
 		
 		if(agentNo_select.length==0){
 			$("#protocolNo").val("");
 			$("#agentName").val("");
 			serviceInfoWrite();
 			$("#commRateSpan").empty();
 			return;
 		}
 		
 		for (var i = 0; i < agent_agreement_list.length; i++) {
 			var AGENTCODE = agent_agreement_list[i].AGENTCODE;
			if(agentNo_select == AGENTCODE){
				$("#protocolNo").val(agent_agreement_list[i].AGREEMENTNO);
				$("#agentName").val(agent_agreement_list[i].AGENTNAME);
				$("#feeMaxRate").val(agent_agreement_list[i].FEEMAXRATE);
				$("#feeMinRate").val(agent_agreement_list[i].FEEMINRATE);
				$('#commRateSpan').html("上限:"+agent_agreement_list[i].FEEMAXRATE+",下限:"+agent_agreement_list[i].FEEMINRATE);
				break;
			}
 		}
	}
 	
	//代理人代码可选状态
	function agentInfoSelect(){
		$('#agentNo_select_div').css('display','inline').val("");
		$('#agentNo').hide().val('');
		
		$('#agentName').attr("readonly",true).css('background-color','#ccc').val("");
		$('#protocolNo').attr("readonly",true).css('background-color','#ccc').val("");
		$("#commRateSpan").empty();
		
		$('#feeMinRate').val("0");
		$('#feeMaxRate').val('1');
	}
 	
	//代理人代码、代理协议号可输入状态
	function agentInfoWrite(){
		$('#agentNo_select_div').css('display','none').val("");
		$('#agentNo').show().val('');
		
		$('#agentName').attr("readonly",false).css('background-color','white').val('');
		$('#protocolNo').attr("readonly",false).css('background-color','white').val('');
		$("#commRateSpan").empty();
		
		$('#feeMinRate').val("0");
		$('#feeMaxRate').val('1');
		
// 		$('#queryAgentAndAgreeInfoBtn').attr('disabled',true).removeClass("input_button_2");
// 		$('#queryServiceNoBtn').attr('disabled',true).removeClass("input_button_2");;
	}
 	
	//查询服务代码信息
	var servicenos_list;//存放销管返回的服务代码和服务名称的List,便于服务代码改变时，服务名称的同步改变
	function queryServiceNo(){
 		var dptCde = $.trim($('#dptCde').val());
 		var channleCode_QD = $.trim($('#channleCode_QD').val());
 		var newBsnsType = $.trim($('#newBsnsType').val());
 		var empNo = $.trim($('#empNo').val());
 		var agentNo = $.trim($('#agentNo').val());
		//必须先选择产品出单机构、归属渠道、业务来源、业务员代码、代理人代码，再获取
		if(dptCde.length==0){$.message('error',"请先选择出单机构");return;}
		if(channleCode_QD.length==0){$.message('error',"请先选择归属渠道");return;}
		if(newBsnsType.length==0){$.message('error',"请先选择业务来源");return;}
		if(empNo.length==0){$.message('error',"请先选择业务员代码");return;}

		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryServiceNo?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				COMCODE:dptCde,
				BUSINESSSOURCE:newBsnsType,
				CHANNELNAME:channleCode_QD,
				USERCODE:empNo,
				AGENTCODE:agentNo
			},
			dataType:'json',
			success:function(result){
				$.closeLoading();
				if($.validate(result)) {
					serviceInfoWrite();
					return;
				}
				
				var select = document.getElementById("serviceCode_select");
				select.options.length = 0;
				select.add(new Option("-----请选择-----",""));
				servicenos_list = result.data;
				for (var i = 0; i < servicenos_list.length; i++) {
					var option = new Option();
					option.text = servicenos_list[i].SERVICENO + "-" + servicenos_list[i].SERVICENAME;
					option.title = servicenos_list[i].SERVICENO + "-" + servicenos_list[i].SERVICENAME;
					option.value = servicenos_list[i].SERVICENO;
					select.add(option);
				}
				serviceInfoSelect();
			}
		});
	}
	
	//服务代码改变时，同步改变服务名称
	function changeServiceCode(){
		var serviceCode_select = $.trim($("#serviceCode_select").val());
 		$("#serviceCode").val(serviceCode_select);
 		
 		if(serviceCode_select.length==0) {
 			$("#serviceName").val("");
 			return;
 		}
 		
 		for (var i = 0; i < servicenos_list.length; i++) {
 			var SERVICENO = servicenos_list[i].SERVICENO;
			if(serviceCode_select == SERVICENO){
				$("#serviceName").val(servicenos_list[i].SERVICENAME);
			}
 		}
	}
	
	//服务代码可选状态
	function serviceInfoSelect(){
		$('#serviceCode_select_div').css('display','inline').val("");
		$('#serviceCode').hide().val('');
		
		$('#serviceName').attr("readonly",true).css('background-color','#ccc').val("");
	}

	
	//服务代码、服务名称可输入状态
	function serviceInfoWrite(){
		$('#serviceCode_select_div').css('display','none').val("");
		$('#serviceCode').show().val('');
		
		$('#serviceName').attr("readonly",false).css('background-color','white').val('');
		
// 		$('#queryServiceNoBtn').attr('disabled',true).removeClass("input_button_2");;
	}
	
	//“审核通过”按钮编辑方案
	function checkAndExcute(flag){
		var agent_type = $('#agentType').val();
		var isInternetPartnerflag = $('#isInternetPartner').val();
		var isPushSaleInfo = $('#isPushedSalesInfo').val();
		if(isInternetPartnerflag =='1' && isPushSaleInfo == 'N' && '1'==agent_type){
			$.message('error',"该方案暂未推送销售信息，不能审核通过");return;
		}
		var planNo = $.trim($('#planNo').val());
		var planName = $.trim($('#planName').val());
		if(planName.length==0){
			$.message("error", "请输入投保方案名称");
			$('#planName').focus();
			return;
		}
		var prodCode = $.trim($('#prodCode').val());
		if(prodCode.length==0){
			$.message("error", "请选择产品编号");
			$('#prodCode').focus();
			return;
		}
		var partnerNo = $.trim($('#partnerNo').val());
		if(partnerNo.length==0){
			$.message("error", "请选择合作伙伴代码");
			$('#partnerNo').focus();
			return;
		}
		
		var channleCode_QD = $.trim($('#channleCode_QD').val());
		var channleType = $.trim($('#channleType').val());
		var newBsnsType = $.trim($('#newBsnsType').val());
		var categoryCode = $.trim($('#bsnsType').val());
		var agentType= $.trim($("#agentType").val());
		//1、合作伙伴代理3、个人代理4、总对总代理
		var dptCde = $.trim($('#dptCde').val());
		if(agentType == "1"){
			if(channleCode_QD.length==0){
				$.message("error", "请选择归属渠道");
				$('#channleCode_QD').focus();
				return;
			}
			if(channleType.length==0){
				$.message("error", "请选择渠道类型");
				$('#channleType').focus();
				return;
			}
			if(newBsnsType.length==0){
				$.message("error", "请选择新业务来源");
				$('#newBsnsType').focus();
				return;
			}
			if(categoryCode.length==0){
				$.message("error", "请选择原业务来源");
				$('#bsnsType').focus();
				return;
			}
			if(dptCde.length==0){
				$.message("error", "请选择出单机构");
				$('#dptCde').focus();
				return;
			}
		}
		
		var commRate = $.trim($('#commRate').val());
		//市场维护费比例文本框判断
		var marketPreserveRate = $.trim($('#marketPreserveRate').val());
			//业务绩效比例文本框判断
		var businessPerformanceRate = $.trim($('#businessPerformanceRate').val());
		//1、合作伙伴代理3、个人代理4、总对总代理
		var empNo = $.trim($('#empNo').val());
		var empName = $.trim($('#empName').val());
		var teamCode = $.trim($('#teamCode').val());
		var teamName = $.trim($('#teamName').val());
		
//		var categoryCode = $.trim($("#newBsnsType").find("option:selected").attr("categoryCode"));
		var agentNo = $.trim($('#agentNo').val());
		var agentName = $.trim($('#agentName').val());
		var protocolNo = $.trim($('#protocolNo').val());
		var serviceCode = $.trim($('#serviceCode').val());
		var serviceName = $.trim($('#serviceName').val());
		if(agentType == "1"){
			if(empNo.length==0){
				$.message("error", "请选择或输入业务员代码");
				$('#empNo').focus();
				return;
			}
		 	//if(empName.length==0){
			//	$.message("error", "请输入业务员名称");
			//	$('#empName').focus();
				//return;
		//	} 
			if(teamCode.length==0){
				$.message("error", "请选择或输入团队代码");
				$('#teamCode').focus();
				return;
			}
			if(teamName.length==0){
				$.message("error", "请输入团队名称");
				$('#teamName').focus();
				return;
			}
			
			//原业务来源为19002-代理或19003-经纪，则代理人代码和代理协议号必填
			if(categoryCode=="19002" || categoryCode=="19003"){
				if(agentNo.length==0){
					$.message("error", "请选择或输入代理人代码");
					$('#agentNo').focus();
					return;
				}
				if(agentName.length==0){
					$.message("error", "请输入代理人名称");
					$('#agentName').focus();
					return;
				}
				if(protocolNo.length==0){
					$.message("error", "请输入代理协议号");
					$('#protocolNo').focus();
					return;
				}
			}
			
			if(serviceCode.length==0){
				$.message("error", "请选择或输入服务代码");
				$('#serviceCode').focus();
				return;
			}
		}
		var applicant_no = $.trim($('#applicant_no').val());
		if(applicant_no.length==0){ 
			$.message("error", "请选择投保人编码");
			return;
		}
		
		var state = $.trim($('#state').val());
		var checkStatus = $.trim($('#checkStatus').val());
		
		//是否电子保单
		var isEpolicy_val = $.trim($('#isEpolicy').val());
		var DownloadWay_val='';
		if(isEpolicy_val==''){
			 $.message("error", "请选择是否电子保单");
			return;
		}else if(isEpolicy_val=='Y'){
			 DownloadWay_val=$.trim($('#DownloadWay').val());
		}else{
			DownloadWay_val='';
		}
		//当“是否打印单证”的值为“是”时，单证领用人可输入
		var isPrintCard = $.trim($('#isPrintCard').val());
		var cardType = $.trim($("#cardType").val());
		var cardApplicant = $.trim($('#cardApplicant').val());

		//当“是否发送短信”的值为“是”时，短信模板配置
		var isMessage = $.trim($('#isMessage').val());
		var messageReceiver = $.trim($('#messageReceiver').val());
		var messageTemplate = $.trim($('#messageTemplate').val());
        //如果短信模板配置的是html，进行转码
		if(messageTemplate!=null){
			messageTemplate=encodeURI(messageTemplate);
		}
			
		var messageReceiver_val = $('#messageReceiver').val();
		//是否回执
		var isReceipt = $.trim($('#isReceipt').val()); //2015年6月1日11:56:40 wangyan add
		var receiptType = $('#receiptType').val();
		//是否分期
		var isPayment = $.trim($('#isPayment').val()); 
		var paymentType = $('#paymentType').val();
		
		 //是否发送电子发票
		var isEpolicyInvoice=$.trim($('#isEpolicyInvoice').val());
		
		//是否开通支付平台
		//var isDredgePay=$.trim($('#isDredgePay').val());
		//是否见费出单
		var isSeeMoney = $.trim($('#isSeeMoney').val());
		//是否发送邮件
		var isEpolicyMali=$.trim($('#isEpolicyMali').val());
		//邮件模板
		var MailTemplate=$.trim($('#MailTemplate').val());
		//转码，可能会传入html的数据
		if(MailTemplate!=null){
			MailTemplate=encodeURI(MailTemplate);
		}
		//获取附加数组
		var selectAccessorys=$('input[name=SendAccessoryBox]:checked');
		//定义一个转换后的字符串
		var selectAccessorylistStr='';
		//判断数组长度
		if(selectAccessorys.length!=0){
			//循环添加
			selectAccessorys.each(function(i){
				var object=new Object();
				object.id=$(this).val();
				map.put(object.id,object);
			});
		}
		//判断map是否为空
		if(!map.isEmpty()){
			//定义list
			var selectAccessorylist =new  Array();
			//循环k值
			for(i in map.keys()){
				//得到key
				var key=map.keys()[i];
				//得到值
				selectAccessorylist.push(map.get(key));
			}
			//转换成字符串
			selectAccessorylistStr=JSON.stringify(selectAccessorylist);
		}
		
		var specialArran = $.trim($('#specialArran').val());
	    var notice =$.trim($('#notice').val());
	    
	    var checkOpinion =$.trim($('#checkOpinion').val());
	    if(checkOpinion.length>1000){
	    	$.message("error", "审核意见超过最大字数");
	    	return;
	    }
		//是否增值服务
		var isAddedService = $('#isAddedService').val();
		//增值服务代码
		var addedServiceCode = $('#addedServiceCode').val();
		//增值服务名称
		var addedServiceName = $('#addedServiceName').val();
		//增值服务次数
		var addedServiceCount = $('#addedServiceCount').val();
		//扫码保业务是否走重复投保校验
		var mfacadeIsReInsure = $('#mfacadeIsReInsure').val();
		//是否已推送销售信息
		var isPushedSalesInfo = $('#isPushedSalesInfo').val();
		if(flag=="update"){
			excuteUpdate({planNo:planNo,planName:planName,prodCode:prodCode,partnerNo:partnerNo,channleCode:channleCode_QD,channleType:channleType,
				   newBsnsType:newBsnsType,categoryCode:categoryCode,dptCde:dptCde,commRate:commRate,empNo:empNo,empName:empName,
				   teamCode:teamCode,teamName:teamName,agentNo:agentNo,agentName:agentName,protocolNo:protocolNo,serviceCode:serviceCode,serviceName:serviceName,
				   state:state,isEpolicy:isEpolicy_val,isSeeMoney:isSeeMoney,isReceipt:isReceipt,isPrintCard:isPrintCard,cardType:cardType,cardApplicant:cardApplicant,
				   isMessage:isMessage,messageReceiver:messageReceiver,messageTemplate:messageTemplate,specialArran:specialArran,notice:notice,
				   applicantNo:applicant_no,isEinvoice:isEpolicyInvoice,isSendEmail:isEpolicyMali,emailTemplate:MailTemplate,
				   epolicyDownloadWay:DownloadWay_val,receiptType:receiptType,selAccessory:selectAccessorylistStr,marketPreserveRate:marketPreserveRate,
				   businessPerformanceRate:businessPerformanceRate,checkOpinion:checkOpinion,checkStatus:checkStatus,isPayment:isPayment,isAddedService:isAddedService,
				   addedServiceCode:addedServiceCode,addedServiceName:addedServiceName,addedServiceCount:addedServiceCount,paymentType:paymentType,mfacadeIsReInsure:mfacadeIsReInsure,isPushedSalesInfo:isPushedSalesInfo});
		}
	}
	
	//方案审核意见修改
	function excuteUpdate(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanCheck/addOrCheckNlifePlanCheck?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(data){
				$.closeLoading();
				if($.validate(data))return;
				successBack('edit');
			}
		});
	}
	
	//编辑成功后返回主页面
	function successBack(flag){
		window.location.href = "<%=path%>/nlifePlanCheck/successBack?flag="+flag;
	}
	
	
	//“审核退回”按钮
 function goBackToList(){
	 var state = $('#state').val();
	    if('1' == state){
			$('#state').val('0');
		}
	    var checkStatus = $('#checkStatus').val();
	    if("未审核"==checkStatus||""==checkStatus) {
	    	$('#checkStatus').val('退回');
	    }
 	} 

<%--***************************************************** --%>
	////加载个人代理(agentType==3)代理信息前，拼接参数
	function queryAgentInfoRela3(pageIndex){
		var size = 5;
		var planNo = $.trim($('#planNo').val());
		var agentType ="3";
		loadAgentInfoRela3({size:size,current:pageIndex,planNo:planNo,agentType:agentType});
	}
	
	//加载个人代理信息
	function loadAgentInfoRela3(param){
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoRelaPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;

				var fieldNames = "USER_CODE,USER_NAME,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE,COMM_RATE,market_rate,business_rate";
				var tableContent = creatTable1(fieldNames,page);
				var tableObj = $("#agentInfoRela3Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage3(param.current,6,page.maxPage,"45");
				var pageDIV = $("#agentInfoRela3PageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
			}
		});
	}
	
	//加载总对总代理(agentType==4)代理信息前，拼接参数
	function queryAgentInfoRela4(pageIndex){
		var size = 5;
		var planNo = $.trim($('#planNo').val());
		var agentType ="4";
		loadAgentInfoRela4({size:size,current:pageIndex,planNo:planNo,agentType:agentType});
	}
	
	//加载总对总代理信息
	function loadAgentInfoRela4(param){
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoRelaPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				var fieldNames;
				var flang=false;
				if($.validate(page))return;
					$.each(page.data, function(k, v){
					 if(v.TRANSTYPE=='1'){
						 flang=true;
					 }
					 return false; 
					});
					if(page.data==''){
						flang=true;
					}
					if(flang){
						fieldNames = "BRANCH,BRANCH_NAME,USERCODE,USERNAME,ZONE,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,,C_BRKR_NME,C_OPR_CDE,COMM_RATE,market_rate,business_rate";
						$("#agentInfoRela4Table tr:eq(1) td:eq(0)").attr("colspan",22).siblings().remove();

					}else{
						if(	$("#agentInfoRela4Table tr th:eq(2)").html()=="用户名"){
							$("#agentInfoRela4Table tr th:eq(2)").remove();
							$("#agentInfoRela4Table tr th:eq(2)").remove();
						}
						fieldNames = "BRANCH,BRANCH_NAME,ZONE,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE,COMM_RATE,market_rate,business_rate";
						$("#agentInfoRela4Table tr:eq(1) td:eq(0)").attr("colspan",20).siblings().remove();

					}
				var tableContent = creatTable1(fieldNames,page);
				var tableObj = $("#agentInfoRela4Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage3(param.current,6,page.maxPage,"46");
				var pageDIV = $("#agentInfoRela4PageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
			}
		});
	}
	//加载联合出单代理(agentType==5)代理信息前，拼接参数
	function queryAgentInfoRela5(pageIndex){
		var size = 5;
		var planNo = $.trim($('#planNo').val());
		var agentType ="5";
		loadAgentInfoRela5({size:size,current:pageIndex,planNo:planNo,agentType:agentType});
	}
	
	//加载联合出单代理信息
	function loadAgentInfoRela5(param){
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoRelaPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				var fieldNames;
				var flang=false;
				if($.validate(page))return;
				fieldNames = "DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE,COMM_RATE,market_rate,business_rate,Key1,key2,key3,key4,key5";
				var tableContent = creatTable1(fieldNames,page);
				var tableObj = $("#agentInfoRela5Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				var strPage = creatChannelPage3(param.current,6,page.maxPage,"60");
				var pageDIV = $("#agentInfoRela5PageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
			}
		});
	}
	
	//点击"配置个人销售业务信息", 弹出个人代理信息选择层
	function openAgentInfo3Div(){
		//加载第一页个人代理信息
		queryAgentInfo3(1);
	}
	
	//点击"配置总对总销售业务信息", 弹出总对总代理信息选择层
	function openAgentInfo4Div(){
		//加载第一页总对总代理信息
		queryAgentInfo4(1);
	}
	
	//点击"配置联合出单销售业务信息", 弹出联合出单代理信息选择层
	function openAgentInfo5Div(){
		//加载第一页联合出单代理信息
		queryAgentInfo5(1);
	}
	
	//加载个人代理信息前，拼接参数
	function queryAgentInfo3(pageIndex){
		var planNo = $.trim($('#planNo').val());
		if(planNo.length==0){
			$.message("error", "请先保存投保方案");
			return;
		}
		var partnerNo = $.trim($("#partnerNo").val());
		if(planNo.length==0){
			$.message("error", "请先选择合作伙伴代码");
			return;
		}
		
		var selectedAgentInfo3 = $("input[name='agentInfo3checkbox']:checked");
		if(selectedAgentInfo3.length!=0){
			var flag= false;
			selectedAgentInfo3.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var commRate= $.trim(obj.val());
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
			        if(!reg.test(commRate)){
			        	flag = true;
			        	$.message("error","手续费比例：只能录入0到1之间的有效数字");
			        	window.setTimeout(function(){ obj.focus(); }, 0);
			        	return false; 
			        }
			    }
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo3.length!=0){
			selectedAgentInfo3.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				obj.cardapplicant= $(this).parent().parent().children("td:eq(7)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				map.put(obj.id,obj);
			});
		}
		
		var agentType = '3';
		var size = 10;
		
		var confStatus = $.trim($("#confStatus_3").val());
		var userCode = $.trim($("#userCode").val());
		var userName = $.trim($("#userName").val());
		
		loadAgentInfo3({size:size,current:pageIndex,planNo:planNo,partnerNo:partnerNo,agentType:agentType,confStatus:confStatus,userCode:userCode,userName:userName});
	}
	
	//加载总对总代理信息前，拼接参数
	function queryAgentInfo4(pageIndex){
		var planNo = $.trim($('#planNo').val());
		if(planNo.length==0){
			$.message("error", "请先保存投保方案");
			return;
		}
		var partnerNo = $.trim($("#partnerNo").val());
		if(planNo.length==0){
			$.message("error", "请先选择合作伙伴代码");
			return;
		}
		
		var selectedAgentInfo4 = $("input[name='agentInfo4checkbox']:checked");
		if(selectedAgentInfo4.length!=0){
			var flag= false;
			selectedAgentInfo4.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var commRate= $.trim(obj.val());
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
			        if(!reg.test(commRate)){
			        	flag = true;
			        	$.message("error","手续费比例：只能录入0到1之间的有效数字");
			        	window.setTimeout(function(){ obj.focus(); }, 0);
			        	return false; 
			        }
			    }
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo4.length!=0){
			selectedAgentInfo4.each(function(i){
				var obj = new Object();
			    var columnes=$("#agentInfo4Table").find("th").length;
			    if(columnes==15){
					obj.id= $(this).parent().parent().children("td:eq(1)").html();
					obj.cardapplicant= $(this).parent().parent().children("td:eq(10)").html();
			    }else if(columnes==17){
			    	obj.id= $(this).parent().parent().children("td:eq(1)").html();
					obj.cardapplicant= $(this).parent().parent().children("td:eq(12)").html();
			    }
		
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				map.put(obj.id,obj);
			});
		}
		
		var agentType = '4';
		var size = 10;
		
		var confStatus = $.trim($("#confStatus_4").val());
		var branch = $.trim($("#branch").val());
		var branchName = $.trim($("#branchName").val());
		
		loadAgentInfo4({size:size,current:pageIndex,planNo:planNo,partnerNo:partnerNo,agentType:agentType,confStatus:confStatus,branch:branch,branchName:branchName});
	}
	
	//加载联合出单代理信息前，拼接参数
	function queryAgentInfo5(pageIndex){
		var planNo = $.trim($('#planNo').val());
		if(planNo.length==0){
			$.message("error", "请先保存投保方案");
			return;
		}
		var partnerNo = $.trim($("#partnerNo").val());
		if(planNo.length==0){
			$.message("error", "请先选择合作伙伴代码");
			return;
		}
		
		var selectedAgentInfo5 = $("input[name='agentInfo5checkbox']:checked");
		if(selectedAgentInfo5.length!=0){
			var flag= false;
			selectedAgentInfo5.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var commRate= $.trim(obj.val());
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
			        if(!reg.test(commRate)){
			        	flag = true;
			        	$.message("error","手续费比例：只能录入0到1之间的有效数字");
			        	window.setTimeout(function(){ obj.focus(); }, 0);
			        	return false; 
			        }
			    }
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo5.length != 0){
			selectedAgentInfo5.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				obj.cardapplicant= $(this).parent().parent().children("td:eq(7)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.market= $(this).parent().parent().find("input[name='marketRate_Div']").val();
				obj.business= $(this).parent().parent().find("input[name='businessRate_Div']").val();
				map.put(obj.id,obj);
			});
		}
		
		var agentType = '5';
		var size = 10;
		
		var confStatus = $.trim($("#confStatus_5").val());
		var key1 = $.trim($("#key1").val());
		var key2 = $.trim($("#key2").val());
		var key3 = $.trim($("#key3").val());
		var key4 = $.trim($("#key4").val());
		var key5 = $.trim($("#key5").val());
		
		loadAgentInfo5({size:size,current:pageIndex,planNo:planNo,partnerNo:partnerNo,agentType:agentType,confStatus:confStatus,key1:key1,key2:key2,key3:key3,key4:key4,key5:key5});
	}
	
	
	//加载个人代理信息
	function loadAgentInfo3(param){
		$.openLoading();
		$.ajax({							
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;

				var checkboxObj ="<input name='agentInfo3checkbox' type='checkbox'>";
				var fieldNames = "ID@TDH,USER_CODE,USER_NAME,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO";
				var inputObj ="<input style='width:100%' name='commRate_Div' onchange='changeCommRate_Div(this)'/>";
				var tableContent = creatTable1(fieldNames,page,checkboxObj,inputObj);
				var tableObj = $("#agentInfo3Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage4(param.current,6,page.maxPage,"47");
				var pageDIV = $("#agentInfo3Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
				$("#agentInfo3Table").find("tr").each(function(){
					var id = $(this).children("td:eq(1)").html();
					if(map.containsKey(id)){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='agentInfo3checkbox']").prop("checked",true);
						$(this).find("input[name='commRate_Div']").val(map.get(id).commrate);
					}
				});
				
				$('#agentInfo3Div').OpenDiv();
				
				bindradio();
			}
		});
	}
	
	//加载总对总代理信息
	function loadAgentInfo4(param){
		$.openLoading();
		$.ajax({							
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				var flang=false;
				var fieldNames ;
				$.closeLoading();
				if($.validate(page))return;
				if(page.data==null){
					$.message("error","请配置销售管理信息");
					return ;
				}
				$.each(page.data, function(k, v){
					 if(v.TRANSTYPE=='1'){
						 flang=true;
					 }
					 return false; 
					});
			
				var checkboxObj ="<input name='agentInfo4checkbox' type='checkbox'>";
				if(flang){
				 fieldNames = "ID@TDH,CHANNEL_CODE@TDH,SUB_CHANNEL_CODE@TDH,BRANCH,BRANCH_NAME,USERCODE,USERNAME,ZONE,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO";
				 $("#agentInfo4Table tr:eq(1) td:eq(0)").attr("colspan",17).siblings().remove();
				}else {
					  if($("#agentInfo4Table tr th:eq(3)").html()=="用户名"){
					    	$("#agentInfo4Table tr th:eq(3)").remove();
							$("#agentInfo4Table tr th:eq(3)").remove();
					    }
					$("#agentInfo4Table tr:eq(1) td:eq(0)").attr("colspan",15).siblings().remove();
				 fieldNames = "ID@TDH,CHANNEL_CODE@TDH,SUB_CHANNEL_CODE@TDH,BRANCH,BRANCH_NAME,ZONE,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO";
				}
				var inputObj ="<input style='width:100%' name='commRate_Div' onchange='changeCommRate_Div(this)'/>";
				var tableContent = creatTable1(fieldNames,page,checkboxObj,inputObj);
				var tableObj = $("#agentInfo4Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage4(param.current,6,page.maxPage,"48");
				var pageDIV = $("#agentInfo4Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
				$("#agentInfo4Table").find("tr").each(function(){
					var id = $(this).children("td:eq(1)").html();
					if(map.containsKey(id)){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='agentInfo4checkbox']").prop("checked",true);
						$(this).find("input[name='commRate_Div']").val(map.get(id).commrate);
					}
				});
				
				$('#agentInfo4Div').OpenDiv();
				
				bindradio();
			}
		});
	}
	
	//加载联合出单代理信息
	function loadAgentInfo5(param){
		$.openLoading();
		$.ajax({							
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				var fieldNames ;
				$.closeLoading();
				if($.validate(page))return;
				if(page.data==null){
					$.message("error","请配置销售管理信息");
					return ;
				}
				/* $.each(page.data, function(k, v){
					 if(v.TRANSTYPE=='1'){
						 flang=true;
					 }
					 return false; 
				}); */
				var checkboxObj ="<input name='agentInfo5checkbox' type='checkbox'>";
				fieldNames = "ID@TDH,CHANNEL_CODE@TDH,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE,key1,key2,key3,key4,key5";
				var inputObj ="<input style='width:100%' name='commRate_Div' onchange='changeCommRate_Div(this)'/>@<input style='width:100%' name='marketRate_Div' onchange='changeCommRate_Div1(this)'/>@<input style='width:100%' name='businessRate_Div' onchange='changeCommRate_Div2(this)'/>";
				
				var tableContent = creatTable1(fieldNames,page,checkboxObj,inputObj);
				var tableObj = $("#agentInfo5Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				var strPage = creatChannelPage4(param.current,6,page.maxPage,"61");
				var pageDIV = $("#agentInfo5Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				$("#agentInfo5Table").find("tr").each(function(){
					var id = $(this).children("td:eq(1)").html();
					if(map.containsKey(id)){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='agentInfo5checkbox']").prop("checked",true);
						$(this).find("input[name='commRate_Div']").val(map.get(id).commrate);
						$(this).find("input[name='marketRate_Div']").val(map.get(id).market);
						$(this).find("input[name='businessRate_Div']").val(map.get(id).business);
					}
				});
				
				$('#agentInfo5Div').OpenDiv();
				
				bindradio();
			}
		});
	}
	
	//点击“保存(已选的个人代理信息)”
	function saveChosenAgentInfo3(){
		var selectedAgentInfo3 = $("input[name='agentInfo3checkbox']:checked");
		if(selectedAgentInfo3.length!=0){
			var flag= false;
			selectedAgentInfo3.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var commRate= obj.val();
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
			        if(!reg.test(commRate)){
			        	$.message("error","手续费比例：只能录入0到1之间的有效数字");
			        	flag = true;
			        	window.setTimeout(function(){ obj.focus(); }, 0);
			        	return false; 
			        }
			    }
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo3.length!=0){
			selectedAgentInfo3.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				obj.cardapplicant= $(this).parent().parent().children("td:eq(7)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				map.put(obj.id,obj);
			});
		}
		var planNo = $("#planNo").val();
		var isPrintCard = $.trim($('#isPrintCard').val());
		
		if(map.isEmpty()){
			$.message("error", "请选择销售业务信息");
			return;
		}else{
			agentInfoList = new Array();
			for(i in map.keys()){
				var key = map.keys()[i];
		        if(isPrintCard=="Y"){//打印单证
		        	if(map.get(key).cardapplicant==""){
			        	$.message("error", "该方案为打印单证,您选择的销售业务信息中存在单证领用人为空的,请调整后添加");
			    		return;
			        }
		        }
		        agentInfoList.push(map.get(key));
		    }
			
			mapBak.clear();
			for(i in map.keys()){
				var key = map.keys()[i];
		        mapBak.put(key,map.get(key));
		    }
			agentInfoListStr=JSON.stringify(agentInfoList);
		}
		
		updateAgentInfoRela({planNo:planNo,isPrintCard:isPrintCard,agentInfoListStr:agentInfoListStr});

		$("#agentInfo3Div").CloseDiv();
	}
	
	//点击“保存(已选的总对总代理信息)”
	function saveChosenAgentInfo4(){
		var selectedAgentInfo4 = $("input[name='agentInfo4checkbox']:checked");
		if(selectedAgentInfo4.length!=0){
			var flag= false;
			selectedAgentInfo4.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var commRate= obj.val();
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
			        if(!reg.test(commRate)){
			        	$.message("error","手续费比例：只能录入0到1之间的有效数字");
			        	flag = true;
			        	window.setTimeout(function(){ obj.focus(); }, 0);
			        	return false; 
			        }
			    }
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo4.length!=0){
			selectedAgentInfo4.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				  var columnes=$("#agentInfo4Table").find("th").length;
				    if(columnes==15){
						obj.cardapplicant= $(this).parent().parent().children("td:eq(10)").html();
				    }else if(columnes==17){
						obj.cardapplicant= $(this).parent().parent().children("td:eq(12)").html();
				    }
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				map.put(obj.id,obj);
			});
		}
		var planNo = $("#planNo").val();
		var isPrintCard = $.trim($('#isPrintCard').val());
		
		if(map.isEmpty()){
			$.message("error", "请选择销售业务信息");
			return;
		}else{
			agentInfoList = new Array();
			for(i in map.keys()){
				var key = map.keys()[i];
		        if(isPrintCard=="Y"){//打印单证
		        	if(map.get(key).cardapplicant==""){
			        	$.message("error", "该方案为打印单证,您选择的销售业务信息中存在单证领用人为空的,请调整后添加");
			    		return;
			        }
		        }
		        agentInfoList.push(map.get(key));
		    }
			
			mapBak.clear();
			for(i in map.keys()){
				var key = map.keys()[i];
		        mapBak.put(key,map.get(key));
		    }
			agentInfoListStr=JSON.stringify(agentInfoList);
		}
		
		updateAgentInfoRela({planNo:planNo,isPrintCard:isPrintCard,agentInfoListStr:agentInfoListStr});

		$("#agentInfo4Div").CloseDiv();
	}	
	
	//点击“保存(已选的联合出单代理信息)”
	function saveChosenAgentInfo5(){
		var selectedAgentInfo5 = $("input[name='agentInfo5checkbox']:checked");
		if(selectedAgentInfo5.length!=0){
			var flag= false;
			selectedAgentInfo5.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var obj1=$(this).parent().parent().find("input[name='marketRate_Div']");
				var obj2=$(this).parent().parent().find("input[name='businessRate_Div']");
				var commRate= obj.val();
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
			        if(!reg.test(commRate)){
			        	$.message("error","手续费比例：只能录入0到1之间的有效数字");
			        	flag = true;
			        	window.setTimeout(function(){ obj.focus(); }, 0);
			        	return false; 
			        }
			    }
				var commRate1= obj1.val();
				if(commRate1!=""){
					var reg=/^0(\.\d{0,4})?$/;
			        if(!reg.test(commRate1)){
			        	$.message("error","市场维护费比例：只能录入0到1之间的有效数字");
			        	flag = true;
			        	window.setTimeout(function(){ obj1.focus(); }, 0);
			        	return false; 
			        }
			    }
				var commRate2= obj2.val();
				if(commRate2!=""){
					var reg=/^0(\.\d{0,4})?$/;
			        if(!reg.test(commRate2)){
			        	$.message("error","业务绩效比例：只能录入0到1之间的有效数字");
			        	flag = true;
			        	window.setTimeout(function(){ obj2.focus(); }, 0);
			        	return false; 
			        }
			    }
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo5.length!=0){
			selectedAgentInfo5.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				obj.cardapplicant= $(this).parent().parent().children("td:eq(7)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.market= $(this).parent().parent().find("input[name='marketRate_Div']").val();
				obj.business= $(this).parent().parent().find("input[name='businessRate_Div']").val();
				map.put(obj.id,obj);
			});
		}
		var planNo = $("#planNo").val();
		var isPrintCard = $.trim($('#isPrintCard').val());
		for(i in map.keys()){
			var key = map.keys()[i];
	       if(key==undefined){
	    	   map.remove(key)
	       }
	    }
		if(map.isEmpty()){
			$.message("error", "请选择销售业务信息");
			return;
		}else{
			agentInfoList = new Array();
			for(i in map.keys()){
				var key = map.keys()[i];
		        if(isPrintCard=="Y"){//打印单证
		        	if(map.get(key).cardapplicant==""){
			        	$.message("error", "该方案为打印单证,您选择的销售业务信息中存在单证领用人为空的,请调整后添加");
			    		return;
			        }
		        }
		        agentInfoList.push(map.get(key));
		    }
			
			mapBak.clear();
			for(i in map.keys()){
				var key = map.keys()[i];
		        mapBak.put(key,map.get(key));
		    }
			agentInfoListStr=JSON.stringify(agentInfoList);
		}
		updateAgentInfoRela({planNo:planNo,isPrintCard:isPrintCard,agentInfoListStr:agentInfoListStr});

		$("#agentInfo5Div").CloseDiv();
	}
	
	//更新方案关联的代理信息
	function updateAgentInfoRela(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/updateAgentInfoRela?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(data){
				$.closeLoading();
				if($.validate(data))return;

				var agentType= $.trim($("#agentType").val());
				if(agentType=="3"){
					queryAgentInfoRela3(1);
				}
				if(agentType=="4"){
					queryAgentInfoRela4(1);
				}
				if(agentType=="5"){
					queryAgentInfoRela5(1);
				}
			}
		});
	}
	
	//关闭 个人/总对总销售业务信息配置  弹出层
	function closeAgentInfoDiv(obj){
		var selectedAgentInfo = $("input[name^=agentInfo]:checked");
		if(selectedAgentInfo.length!=0){
			selectedAgentInfo.each(function(i){
				$(this).prop("checked",false);
			});
		}
		
		map.clear();
		for(i in mapBak.keys()){
			var key = mapBak.keys()[i];
	        map.put(key,mapBak.get(key));
	    }
		
		$("#confStatus_3").val("");
		$("#userCode").val("");
		$("#userName").val("");
		
		$("#confStatus_4").val("");
		$("#branch").val("");
		$("#branchName").val("");
		
		$("#confStatus_5").val("");
		$("#key1").val("");
		$("#key2").val("");
		$("#key3").val("");
		$("#key4").val("");
		$("#key5").val("");
		
		$("#"+obj).CloseDiv();	
	}
	function SeeMoneyChange (){
		var isSeeMoney =$('#isSeeMoney').val();
		if(isSeeMoney== "N"){
			//$('#isDredgePay').val(1);
			//$('#isDredgePay').attr("disabled",true);
			//$("#isDredgePay").css({"background-color": "#ccc"});
		}else{
			//$("#isDredgePay").attr("disabled",false);
			//$("#isDredgePay").css({"background-color": ""});
		}
	}
	$(document).ready(function(){
		queryIfInternetPlan();
		//旧业务来源
		$("#bsnsType").change(function(){
			var newBsnsCode = $("#newBsnsType").val();
			var bsnsTypeCode = $("#bsnsType").val();
			//原业务来源为19002-代理或19003-经纪，则代理人代码和代理协议号必填，其他非必填
			$("#agentNoButtonHidden").empty();
			if(bsnsTypeCode!="19002"&&bsnsTypeCode!="19003"){
//	 			$("#agentNo ~ span").remove(".red");
				$("#agentNo").val("");
				$('#agentNo').attr("disabled",true);
				$("#agentNo").css({"background-color": "#ccc"});
				$("#agentName").val("");
				$('#agentName').attr("disabled",true);
				$("#agentName").css({"background-color": "#ccc"});
				$("#protocolNo").val("");
				$('#protocolNo').attr("disabled",true);
				$("#protocolNo").css({"background-color": "#ccc"});
				$("#agentName ~ span").remove(".red");
				$("#agentNo ~ span").remove(".red");
				$("#protocolNo ~ span").remove(".red");
				$("#agentNoButtonHidden").html("&nbsp;&nbsp;<input type='button'  class='input_button_2 red' id='queryAgentAndAgreeInfoBtn' value='获取' onClick='queryAgentAndAgreeInfo()'/>");
			}else{
				$("#agentNo").attr("disabled",false);
				$("#agentNo").css({"background-color": ""});
				$("#agentName").attr("disabled",false);
				$("#agentName").css({"background-color": ""});
				$("#protocolNo").attr("disabled",false);
				$("#protocolNo").css({"background-color": ""});
				if($("#agentNo ~ span").length==0){
					$("#agentNo").parent().append("<span class='red'>*</span>");
				}
				if($("#agentName ~ span").length==0){
					$("#agentName").parent().append("<span class='red'>*</span>");
				}
				if($("#protocolNo ~ span").length==0){
					$("#protocolNo").parent().append("<span class='red'>*</span>");
				}
				$("#agentNoButtonHidden").html("<span class='red' style='margin-left: -5px'>*</span>&nbsp; <input type='button'  class='input_button_2 red' id='queryAgentAndAgreeInfoBtn' value='获取' onClick='queryAgentAndAgreeInfo()'/>");
			}
		});
		isHideAddedServiceInfo();
		if ('6'==$('#agentType').val()){
			$("#unionMessageConfig").css('display','');
		}
	});
	function isHideAddedServiceInfo(){
		var isAddedService = $('#isAddedService').val();
		if(isAddedService =='Y'){
			$('#addedServiceInfo1').show();
			$('#addedServiceInfo2').show();
			$('#addedServiceInfo3').show();
		}else{
			$('#addedServiceInfo1').hide();
			$('#addedServiceInfo2').hide();
			$('#addedServiceInfo3').hide();
		}
	}
	function checkIfPushedSalesInfo(){
		var agentType = "";
	}
	//判断是否网销专属合作伙伴
	function queryIfInternetPlan(){
		var partnerCode = $("#partnerNo").val();
		var date = {partnerCode:partnerCode};
		$.ajax({
			url : "nlifePlanConfig/queryIfInternetPlan",
			type : 'POST',
			async : true,
			data : date,
			dataType : "json",
			success:function(map){
				var riskToplimit = parseFloat(map["riskToplimit"]).toFixed(6);
				var isInternetPartner = map["flag"];
				$("#isInternetPartner").val(isInternetPartner);
			}
		});
	}
</script>

<body>
<%-- 是否网销专属合作伙伴--%>
<input type="hidden"  id="isInternetPartner" value=""/>
	    <div class="current">
           <table class="current_table_1">
              <tbody>
                <tr class="f2">
                  <td>
                    <img src="./images/current_1.jpg">
                  </td>
                  <td class="current_table_1_td">
                    <img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                      <span style=" color:#136bab; ">新意健险产品管理
                         <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>方案审核
                         <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>
                         	<c:if test="${not empty planNo }">方案审核编辑</c:if>
                      </span>
                  </td>
                  <td><img src="./images/current_3.jpg"></td>
              </tr>
           </tbody>
         </table>
      </div>

		<c:choose>
			<c:when test="${not empty planNo}">
				<input type="hidden" value="${planNo }" id="hidePlanNo">
			</c:when>
			<c:when test="${not empty oldPlanNo}">
				<input type="hidden" value="${oldPlanNo }" id="hidePlanNo">
			</c:when>
		</c:choose>		
		<form id="inputForm">
	        <table class="table_05">
              <tbody>
	              <tr>
	                  <td colspan="4" style=" font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:17px; background-image:url(images/centent_1.jpg)">
	                  	<c:if test="${not empty planNo}">方案审核编辑</c:if>
	                  	
	                  </td>
	              </tr>
	    		  <tr>
	                  <th width="10%">投保方案号：</th>
	                  <td width="40%"><input name="planNo" id="planNo" readonly="readonly" style="background-color: #ccc;" class="input_text"><span class="red">*</span></td>
	                  <th width="10%">投保方案名称：</th>
	                  <td width="40%"><input id="planName"  id="planName" class="input_text" ><span class="red">*</span></td>
	              </tr>
	              <tr>
	                  <th>产品编号：</th>
	                  <td>
	                  	<input name="prodCode" id="prodCode" readonly="readonly" style="background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;
	                  	<c:if test="${empty planNo}">
	                  		<input type="button"  class="input_button_2" id="searchProdBtn" value="请选择" onClick="openNlifeProdDiv(1,this)"/>
	                  	</c:if>
	                  	<c:if test="${not empty planNo}">
	                  		<input type="button" disabled="disabled" id="searchProdBtn" value="请选择" onClick="openNlifeProdDiv(1,this)"/>
	                  	</c:if>
	                  	<input type="hidden" id="prodSaleCode"/><!-- 选择产品时赋值，该值是为了向销管获取代理信息时传参 -->
	                  </td>
	                  <th>合作伙伴代码：</th>
	                  <td>
	                  	<input name="partnerNo" id="partnerNo" readonly="readonly" style="background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;
	                  	<c:if test="${empty planNo}">
	                  		<input type="button"  class="input_button_2" id="searchChannelInfoBtn" value="请选择" onClick="openChannelInfoDiv()"/>
	                  	</c:if>
	                  	<c:if test="${not empty planNo}">
	                  		<input type="button" disabled="disabled"  id="searchChannelInfoBtn" value="请选择" onClick="openChannelInfoDiv()"/>
	                  	</c:if>
	                  </td>
	              </tr>
	               <tr>
	              	  <th id='cRate'>手续费比例：</th>
	                  <td>
	                  	<input name="commRate" id="commRate" class="input_text" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
	                  	<span class="red" style="margin-left: -5px">*</span>&nbsp;<span id="commRateSpan" class="blue"></span>
	                  	<!-- 手续费比例上下限，验证使用 -->
	                  	<input id="feeMaxRate" type="hidden" value="1"/>
	                  	<input id="feeMinRate" type="hidden" value="0"/>
	                  </td>
	                    <th id='mRate'>市场维护费比例：</th>
					  		<td>
	                  	<input name="marketPreserveRate" id="marketPreserveRate" class="input_text" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
	                  </td>
	              </tr>
	              <!-- 增加市场维护费比例、业务绩效比例文本开始 -->
					  <tr>
						  <th id='bRate'>业务绩效比例：</th>
						  <td>
		                  	<input name="businessPerformanceRate" id="businessPerformanceRate" class="input_text" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
	                  	</td>
	                    <th>是否见费出单：
	              	  </th>
		                  <td>
		                   <div style="float:left;  height: 34px ;width:50%;  padding-top:11px;"> 
			                  <select id="isSeeMoney" class="select_1 valid" onchange="SeeMoneyChange()" style="visibility: visible;">
				                  <option value="N">否</option>
				                  <option value="Y">是</option>
				                   <option value="YD">见费已缴费</option>
			                  </select>
			                </div>
			                 <div style="height: 45px ;width:46%;float: left; ">
		                 	 	<span class="red" id='notice_1' style="padding-left: 15px; display: none;">注意：此为非常规流程，请线下沟通确认</span>
		                 	 </div>  
		                  </td>
					  </tr>
					   <tr>
	              	  <th>方案销售类型：</th>
	                  <td>
                  		<select id="agentType" name="agentTypeSel" onchange="agentChange()" class="select_1 valid" style="visibility: visible;">
								<c:forEach var ="agentType" items="${agentTypes}">
                  				<option value="${agentType.code}" title="${agentType.codeName}">${agentType.codeName}</option>
                  			</c:forEach>
                  		</select>
                 			<select name="unionType"  id="unionType" class="select_1 valid" style="visibility: visible;display: none;">
							<option value="">请选择联合出单方案</option>
							<c:forEach var ="unionType" items="${unionTypes}">
			                	<option value="${unionType.code}">${unionType.codeName}</option>
			                </c:forEach>					  			
	                	</select>
						  <input type="button" id="unionMessageConfig" onclick="openMessageConfig()" style="display: none" value="车加意-关联信息配置" title="注意：仅车加意方案需进行此配置">
					  </td>
	                  <th>跟单费用配置：</th>
	                  <td>
	                  	<select id="agentFeeConfig" name="agentFeeConfig" onchange="agentFeeConfigChange()" class="select_1 valid" style="visibility: visible;background-color: #ccc;"  disabled="disabled">
		                  	 <option value="" >请选择</option>
                  			 <option value="1" >接口传入</option>
		                  	 <option value="2" >合作伙伴配置</option>
                  		</select>
	                  </td>
	              </tr>
	              <tr id="quDao01">
	                  <th>归属渠道：</th>
	                  <td>
		                  <select id="channleCode_QD" name="channleCode_QD" onchange="changeChannleCode_QD()" class="select_1 valid" style="visibility: visible;">
	                  		<option value="">-----请选择-----</option>
	                  		<c:forEach var ="belongToChannel" items="${belongToChannelList}">
	                  			<option value="${belongToChannel.code}" title="${belongToChannel.codeName}">${belongToChannel.codeName}</option>
	                  		</c:forEach>
		                  </select><span class="red">*</span>
	                  </td>
	                  <th>渠道类型：</th>
	                  <td>
		                  <select id="channleType"  class="select_1 valid" onchange="changeChannleType()" style="visibility: visible;">
	                  		<option value="">-----请选择归属渠道-----</option>
	                  		<c:forEach var ="channelType" items="${channelTypeList}">
	                  			<option value="${channelType.code}" title="${channelType.codeName}">${channelType.codeName}</option>
	                  		</c:forEach>
	                  	  </select><span class="red">*</span>
	                  </td>
	              </tr>
	              <tr id="quDao02">
	                  <th>新业务来源：</th>
		                  <td>
		                  	  <select id="newBsnsType"  onchange = "changeNewBsnsType()" class="select_1 valid" style="visibility: visible;" name="Ssss">
		                  		<option value="">-----请选择渠道类型-----</option>
		                  		<c:forEach var ="newBSList" items="${newBSList}">
		                  			<option value="${newBSList.code}">${newBSList.codeName}</option>
		                  		</c:forEach>
		                  	  </select><span class="red">*</span>
		                  </td>
		                  <th>原业务来源：</th>
		                  <td>
		                  	  <select id="bsnsType" onchange = "bsnsTypechange()" class="select_1 valid" style="visibility: visible;">
		                  		<option value="">-----请选择-----</option>
		                  		<c:forEach var ="oldBSList" items="${oldBSList}">
		                  			<option value="${oldBSList.code}">${oldBSList.codeName}</option>
		                  		</c:forEach>
		                      </select><span class="red">*</span>
		                  </td>
	              </tr>
	              <tr>
	              	  <th id="deptCode101">出单机构：</th>
	                  <td id="deptCode102">
	                  	<input id="dptCde" readonly="readonly" style="background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;
	                  	<input type="button"  class="input_button_2" id="searchDeptBtn" value="请选择" onClick="openDeptDiv()"/>
	                  </td>
	                  <th>投保人编码：</th>
		                  <td><div style="float:left;  height: 34px ;width:50%;  padding-top:11px;"><select id="applicant_no"  align = "center" class="select_1 valid" style="visibility: visible;">
		                  	 <option value="0" >0</option>
		                  	 <option value="1" >1</option>
		                  	 </select><span class="red">*</span></div><div style="height: 45px ;width:46%;float: left; ">
		                 	 <span style="color: blue;padding-left: 15px;">投保时需录入投保人时选0，投保人为合作伙伴时选编码1</span></div>
		                  </td>
	              </tr>
<!--begin --------------------------根据产品销售方式的不同改变以下内容-------------------------------------- -->
              	  <!--agentType1  合作伙伴代理   -->
              	  <tr id="agentType101">
	                  <th>业务员代码：</th>
		              <td>
		              	<div id="empNo_select_div" style="display: none">
		              		<select id="empNo_select" onchange="changeEmpNo()" class="select_1"></select>
		              	</div>
		              	<input id="empNo" class="input_text" maxlength="10"/>
		              	<span class="red" style="margin-left: -5px">*</span>&nbsp;	
		              </td>
		              <th>业务员名称：</th>
		              <td><input id="empName" class="input_text"><!-- <span class="red">*</span> --></td>
		          </tr>
		          <tr id="agentType102">
					  <th>团队代码：</th>
					  <td>
						  <div id="teamCode_select_div" style="display: none" >
							 <select id="teamCode_select" onchange="changeTeamCode()" class="select_1"></select>
						  </div>
					 	  <input id="teamCode" class="input_text" maxlength="11"/>
					 	  <span class="red" style="margin-left: -5px">*</span>&nbsp;
					  </td>
	                  <th>团队名称：</th>
	                  <td><input id="teamName" class="input_text"><span class="red">*</span></td>
   	              </tr>
	              <tr id="agentType103">
	              	  <th>代理人代码：</th>
	                  <td>
	                  	<div id="agentNo_select_div" style="display: none">
	                  		<select id="agentNo_select" onchange="changeAgentNo()" class="select_1"></select>
	                  	</div>
	                  	<input id="agentNo" class="input_text"/><span class="red" >*</span>
	                  </td>
	                  <th>代理协议号：</th>
	                  <td><input id="protocolNo" class="input_text" maxlength="13"/><span class="red" >*</span></td>
	              </tr>
	              <tr id="agentType105">
	                  <th>代理人名称：</th>
	                  <td><input id="agentName" class="input_text" maxlength="13"/><span class="red" >*</span></td>
	              </tr>
	              <tr id="agentType104">
	                  <th>服务代码：</th>
	                  <td>
	                  	<div id="serviceCode_select_div" style="display: none">
	                  		<select id="serviceCode_select" onchange="changeServiceCode()" class="select_1"></select>
	                  	</div>
	                  	<input id="serviceCode" class="input_text"/>
	                  	<span class="red" style="margin-left: -5px">*</span>&nbsp;
	                  </td>
	                  <th>服务名称：</th>
	                  <td><input id="serviceName" class="input_text"/></td>
	              </tr>
	              <!--广东分公司个人销售业务信息 -->
		              <tr id="sale1" style="display:none">
		                  <th>跟单人员配置信息：</th>
		                  <td colspan="3"><input type="button" disabled="disabled" onclick="opensaleDiv()" value="广东销售信息配置"/></td>
		              </tr>
		              <tr id="sale2" style="display:none">
		                  <td colspan="4">
		                  	<div style="width:1100px; height:200px; overflow:scroll;">
			                  	<table id="agentType3Table"  style="width:99%;">
			                  		<thead>
										<tr style="background-color: C0C0C0;">
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">序号</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">销售员类型<span style="margin-left: -5px" class="red">*</span></th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">销售人员代码<span style="margin-left: -5px" class="red">*</span></th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">销售人员姓名</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">执业证号</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理机构号</th>
						                   <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理机构名称</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">分摊比例<span style="margin-left: -5px" class="red">*</span></th>
						              	</tr>
									</thead>
									<tbody id='saleShowDiv'>
						            </tbody>
			                  	</table>
		                  	</div>
		                  </td>
		              </tr>	
		              <!-- 广东分公司个人销售业务信息结束 -->
   	              <!--agentType3   个人代理   -->
	              <tr id="agentType301" style="display:none">
	              	<c:if test="${not empty planNo }">
	                  <th>个人销售业务信息：</th>
	                  <td colspan="3"><input type="button" onclick="openAgentInfo3Div()" value="配置个人销售渠道信息"/></td>
	              	</c:if>
	              	<c:if test="${empty planNo }">
	                  <th>个人销售业务信息：</th>
	                  <td colspan="3"><input type="button" disabled="disabled" onclick="openAgentInfo3Div()" value="配置个人销售渠道信息"/></td>
	              	</c:if>
	              </tr>
	              <c:if test="${not empty planNo || not empty oldPlanNo}">
				  <tr id="agentType302" style="display:none">
	                  <td colspan="4">
		               <div style="width:1100px; height:auto; overflow:scroll;">
	                  	<table id="agentInfoRela3Table" style="width:1400px;">
	                  		<thead>
								<tr style="background-color: C0C0C0;">
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">用户名</th>
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">姓名</th>
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">出单机构</th>
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">服务代码</th>
				                   <th style="border: #292421 solid 1px;width:100px;text-align: center;">服务名称</th>
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">业务员代码</th>
				                     <th style="border: #292421 solid 1px;width:100px;text-align: center;">业务员名称</th>
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">单证领用人</th>
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">团队代码</th>
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">归属渠道</th>
						          <th style="border: #292421 solid 1px;width:100px;text-align: center;">渠道类型</th>
						          <th style="border: #292421 solid 1px;width:100px;text-align: center;">业务来源</th>
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理人编码</th>
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理协议号</th>
				                    <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理人名称</th>
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">处理人</th>
				                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">手续费比例</th>
				                   <th style="border: #292421 solid 1px;width:100px;text-align: center;">市场维护费比例</th>
				                   <th style="border: #292421 solid 1px;width:100px;text-align: center;">业务绩效比例</th>
				              	</tr>
							</thead>
							<tfoot>
								<tr>
				                  <td colspan="19">
				                  	<div id="agentInfoRela3PageDIV" class="page"></div>
				                  </td>
				              	</tr>
							</tfoot>
							<tbody>
				            </tbody>
	                  	</table>
	                   </div>
	                  </td>
	              </tr>
	              </c:if>	
	              <!--agentType4   总对总代理   -->
	              <tr id="agentType401" style="display:none">
	              	<c:if test="${not empty planNo }">
	                  <th>总对总销售业务信息：</th>
	                  <td colspan="3"><input type="button" onclick="openAgentInfo4Div()" value="配置总对总销售业务信息"/></td>
	              	</c:if>
	              	<c:if test="${empty planNo }">
	                  <th>总对总销售业务信息：</th>
	                  <td colspan="3"><input type="button" disabled="disabled" onclick="openAgentInfo4Div()" value="配置总对总销售业务信息"/></td>
	              	</c:if>
	              </tr>
	              <c:if test="${not empty planNo || not empty oldPlanNo }">
				  <tr id="agentType402">
	                  <td colspan="4">
                       <div style="width:1100px; height:auto; overflow:scroll;">
	                  	<table id="agentInfoRela4Table" style="width:2000px;">
	                  		<thead>
							 <tr style="background-color: C0C0C0;">
				 			  <th style="width:80px;text-align: center;">网点代码</th>
			                  <th style="width:100px;text-align: center;">网点名称</th>
			                  <th style="width:80px;text-align: center;">用户名</th>
			                  <th style="width:80px;text-align: center;">姓名</th>
			                  <th style="width:80px;text-align: center;">区域代码</th>
			                  <th style="width:80px;text-align: center;">出单机构</th>
			                  <th style="width:80px;text-align: center;">服务代码</th>
			                   <th style="width:80px;text-align: center;">服务名称</th>
			                  <th style="width:80px;text-align: center;">业务员代码</th>
			                   <th style="width:80px;text-align: center;">业务员名称</th>
			                  <th style="width:80px;text-align: center;">单证领用人 </th>
			                  <th style="width:80px;text-align: center;">团队代码 </th>
			                  <th style="width:90px;text-align: center;">归属渠道</th>
					          <th style="width:90px;text-align: center;">渠道类型</th>
					          <th style="width:80px;text-align: center;">业务来源</th>
			                  <th style="width:80px;text-align: center;">代理人编码</th>
			                  <th style="width:80px;text-align: center;">代理协议号</th>
			                   <th style="width:80px;text-align: center;">代理人名称</th>
			                   <th style="width:80px;text-align: center;">处理人</th>
			                  <th style="width:80px;text-align: center;">手续费比例 </th>
			                   <th style="width:80px;text-align: center;">市场维护费比例</th>
			                      <th style="width:80px;text-align: center;">业务绩效比例 </th>
				              	</tr>
							</thead>
							<tfoot>
								<tr>
				                  <td colspan="20">
				                  	<div id="agentInfoRela4PageDIV" class="page"></div>
				                  </td>
				              	</tr>
							</tfoot>
							<tbody>
				            </tbody>
	                  	</table>
	                   </div>
	                  </td>
	              </tr>
	              </c:if>
	              <!--agentType5   联合出单代理   -->
				 <tr id="agentType501" style="display:none">
	              	<c:if test="${not empty planNo }">
	                  <th>总对总销售业务信息：</th>
	                  <td colspan="3"><input type="button" onclick="openAgentInfo5Div()" value="配置联合出单销售业务信息"/></td>
	              	</c:if>
	              	<c:if test="${empty planNo }">
	                  <th>总对总销售业务信息：</th>
	                  <td colspan="3"><input type="button" disabled="disabled" onclick="openAgentInfo5Div()" value="配置联合出单销售业务信息"/></td>
	              	</c:if>
	              </tr> 
	              <c:if test="${not empty planNo || not empty oldPlanNo }">
				  <tr id="agentType502">
	                  <td colspan="4">
                       <div style="width:1100px; height:auto; overflow:scroll;">
	                  	<table id="agentInfoRela5Table" style="width:2180px;">
	                  		<thead>
							 <tr style="background-color: C0C0C0;">
				 			  <!-- <th style="width:80px;text-align: center;">网点代码</th>
			                  <th style="width:100px;text-align: center;">网点名称</th>
			                  <th style="width:80px;text-align: center;">用户名</th>
			                  <th style="width:80px;text-align: center;">姓名</th>
			                  <th style="width:80px;text-align: center;">区域代码</th> -->
			                  <th style="width:80px;text-align: center;">出单机构</th>
			                  <th style="width:80px;text-align: center;">服务代码</th>
			                   <th style="width:80px;text-align: center;">服务名称</th>
			                  <th style="width:80px;text-align: center;">业务员代码</th>
			                   <th style="width:80px;text-align: center;">业务员名称</th>
			                  <th style="width:80px;text-align: center;">单证领用人 </th>
			                  <th style="width:80px;text-align: center;">团队代码 </th>
			                  <th style="width:90px;text-align: center;">归属渠道</th>
					          <th style="width:90px;text-align: center;">渠道类型</th>
					          <th style="width:100px;text-align: center;">业务来源</th>
			                  <th style="width:80px;text-align: center;">代理人编码</th>
			                  <th style="width:80px;text-align: center;">代理协议号</th>
			                  <th style="width:80px;text-align: center;">代理人名称</th>
			                  <th style="width:80px;text-align: center;">处理人</th>
			                  <th style="width:80px;text-align: center;">手续费比例 </th>
			                  <th style="width:85px;text-align: center;">市场维护费比例</th>
			                  <th style="width:80px;text-align: center;">业务绩效比例 </th>
			                  <th style="width:80px;text-align: center;">Key1</th>
			                  <th style="width:80px;text-align: center;">Key2</th>
			                  <th style="width:80px;text-align: center;">Key3</th>
			                  <th style="width:80px;text-align: center;">Key4</th>
			                  <th style="width:80px;text-align: center;">Key5</th>
				             </tr>
							</thead>
							<tfoot>
								<tr>
				                  <td colspan="22">
				                  	<div id="agentInfoRela5PageDIV" class="page"></div>
				                  </td>
				              	</tr>
							</tfoot>
							<tbody>
				            </tbody>
	                  	</table>
	                   </div>
	                  </td>
	              </tr>
	              </c:if>
	               <!--agentType6  销售类型6 跟单费用配置接口传入  -->
	              <tr id="agentType601" style="display:none">
	              	<c:if test="${not empty planNo }">
	                  <th>第三方传入方案跟单费用配置：</th>
	                  <td colspan="3"><input type="button" onclick="openAgentInfo6Div()" value="配置联合出单销售渠道信息"/></td>
	              	</c:if>
	              	<c:if test="${empty planNo }">
	                  <th>第三方传入方案跟单费用配置：</th>
	                  <td colspan="3"><input type="button" disabled="disabled" onclick="openAgentInfo6Div()" value="配置联合出单销售渠道信息"/></td>
	              	</c:if>
	              </tr>
	              <c:if test="${not empty planNo || not empty oldPlanNo }">
	               <tr id="agentType602">
	                  <td colspan="4">
                       <div style="height:auto; overflow:scroll;">
                       <span>配置跟单名称：<span id='agentNameTitle'></span> </span>
	                  	<table id="agentInfoRela6Table" style="width: 100%" >
	                  		<thead>
							 <tr style="background-color: C0C0C0;" id="agentFeeTitle">
								 <th style="text-align: center;">机构</th>
								 <th style="text-align: center;">产品大类</th>
								 <th style="text-align: center;">手续费比例（%）</th>
								 <th style="text-align: center;">业务绩效比例（%）</th>
								 <th style="text-align: center;">市场维护费比例（%）</th>
							 </tr>
							</thead>
							<tfoot>
								<tr>
				                  <td colspan="22">
				                  	<div id="agentInfoRela6PageDIV" class="page"></div>
				                  </td>
				              	</tr>
							</tfoot>
							<tbody>
				            </tbody>
	                  	</table>
	                   </div>
	                  </td>
	              </tr>
	              </c:if>
<!-- end --------------------------根据产品销售方式的不同改变以上内容-------------------------------------- -->
				  <tr>
				  	  <th>状态：</th>
	                  <td>
	                  <!--  <select id="state" class="select_1 valid" style="visibility: visible;">-->
	                  <select id="state" onchange="changeState()"   class="select_1 valid" style="background-color: #ccc;" disabled="disabled" >
	                  <option value="0">无效</option>
	                  <option value="1">有效</option>
	                  </select>
	                 <input id="checkStatus"  type="hidden"/>
	                  </td>
	                     <th>是否打印单证：</th>
	                  <td>
	                  	<select id="isPrintCard" onchange="changeIsPrintCard()" class="select_1" style="visibility: visible;">
	                  		<option value="">----请选择----</option>
	                  		<option value="Y">是</option>
	                  		<option value="N">否</option>
	                  	</select><span class="red">*</span>
	                  </td>
				  </tr>
	   			 <tr>
	                  <th>单证类型：</th>
	                  <td>
	                  	<input id="cardType" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>
	                  </td>
	                  <th ><span id='cardApplicant_title'>单证领用人：</span></th>
	                  <td>
	                  	<div id="cardApplicant_div" style="float: left;">
	                  		<input id="cardApplicant" readonly="true" style=" background-color: #ccc; width:100px" onBlur = "testCardApplicant()" class="input_text"><span class="red">*</span>
	                  	</div>
	                  	<div id="cardApplicant_div_cue" >
	                  		<span class="red">单证领用人UM账号</span>
	                  	</div>
	                  </td>
	              </tr>
	              <tr>
             		<th>争议处理方式：</th>
			  		<td colspan="3">
			  			<select name="dicputeType" onchange="dicputeType1()" id="dicputeType" class="select_1 valid" style="visibility: visible;">
							<c:forEach var ="dicputeType" items="${dicputeTypes}">
			                	<option value="${dicputeType.code}">${dicputeType.codeName}</option>
			                </c:forEach>					  			
	                	</select>&nbsp
	                	<select name="arbitrationDept"  id="arbitrationDept" class="select_1 valid" style="visibility: visible;">
							<c:forEach var ="dicputeType" items="${arbitrationDepts}">
			                	<option value="${dicputeType.code}">${dicputeType.codeName}</option>
			                </c:forEach>					  			
	                	</select>
			  		</td>
				  </tr>
					  <tr>
					  	<th>是否发送电子发票：</th>
					    <td>
					    <select id="isEpolicyInvoice" class="select_1 valid" style="visibility: visible;" onchange="epolicyInvoiceChange()"><option value="2">否</option><option value="1">是</option></select>
					      	&nbsp;<span class='CinvockLink' style="display: none">电子发票下载链接&nbsp;</span><select id="invockLink" class="select_1 valid CinvockLink" style="visibility: visible;width: 70px;display: none"><option value="Y">生成</option><option value="N">不生成</option></select>
					    	<img class='CinvockLink'  style="display: none" src="/manager/images/caldef.jpg" title="如果需要接口、邮件、或短信内容包括电子发票发载链接，则需选择“生成”选项">
					    </td>	
						 
						 <th>是否支持回执：</th>
		                 <td>
		                  <div style="float:left;">
		                  		<select name="isReceipt" id="isReceipt" onchange="chooseReceiptType()" class="select_1 valid" style="visibility: visible;"><option value="N">否</option><option value="Y">是</option></select>
		                  </div>
		                  <div id="isOrNotDisplayReceiptTypeDiv"  style="float:left;display:none;">
			              	回执类型：<select id = "receiptType" class="select_1 valid" style="visibility: visible;vertical-align: middle; width: 110px;">
			                    <c:forEach var ="receiptTypeLsCode" items="${receiptTypeLs}">
				                	<option value="${receiptTypeLsCode.code}">${receiptTypeLsCode.codeName}</option>
				                </c:forEach>
			                  </select>
			              </div>
		                  </td>
					  </tr>
					  <tr id="einvoiceInfo" style="display: none">
						<th>发票购方：</th>
				  		<td>
							<select id="payEinvoice" class="select_1 valid" style="visibility: visible;width: 100px;">
                  				<c:forEach var ="payEinvoice" items="${payEinvoices}">
	                  				<option value="${payEinvoice.code}">${payEinvoice.codeName}</option>
	                  			</c:forEach>
		                  	</select>
			  			</td>	
				  		<th >承保时支持开票：</th>
				  		<td >
				  			<select id="isInsuranceEinvoice" class="select_1 valid" style="visibility: visible;" onchange="isInsurEinvoiceChange()"><option value="Y">是</option><option value="N">否</option></select>
				  		</td>						  		
			  		</tr>	 	  
			  	 	<tr>
                     <th>是否电子保单：</th>
	                  <td colspan="1">
	                  		<div id="Download_left" style="float: left;"><select id="isEpolicy" class="select_1 valid" onchange="IsEpolicyChange()" style="visibility: visible; width: 100px"><option value="N">否</option><option value="Y">是</option></select></div>
	                  		<div id="Download_right" style="float: left;display: none;">
								下载方式：<select id="DownloadWay" class="select_1 valid" style="visibility: visible;width: 100px" onchange='downloadWayChange()'><option value="0">实时电子保单</option><option value="1">影像系统获取</option></select>		                  		
	                  			<span style="display: none;" id='fileTypeSpan'>文件方式：
		                  			<select id="fileType" class="select_1 valid" style="visibility: visible;width: 100px;" onchange="fileTypeChange()">
		                  				<c:forEach var ="fileType" items="${fileTypes}">
			                  				<option value="${fileType.code}">${fileType.codeName}</option>
			                  			</c:forEach>
		                  			</select>
	                  			</span>
	                  			<span  class="red" id='propTitle'>
	                  			</span>
	                  		</div>
	                  		<input type="hidden" value="" id="iseplicyFlag"/>
	                  </td>
	                   <th>续保费用比例差值：</th>
	                  <td>
	                  		<input type="text"  id="rateSubtract" readonly="readonly"> 
	                  </td>					
			  		</tr>
			  		<tr>
					  <th>是否发送承保短信：</th>
	                  <td>
	                 	  <div style="float: left;width: 18%;">
	                  		<select name="isMessage" id="isMessage" onchange="changeIsCoreMessage()" class="select_1 valid" style="visibility: visible;width: 95%;">
	                  		<option value="N">否</option>
	                  		<option value="Y">是</option>
	                  		</select>
	                  	  </div>
	                  	  <div id="messageReceiverDiv"  style="float: left;display:none;width: 35%;">
	                  		接收人：<select name="messageReceiver"  id="messageReceiver" class="select_1 valid" style="visibility: visible;width:65%;"><option value="">----请选择----</option><option value="0">投保人</option><option value="1">被保人</option></select>
	                  	  </div>
	                  	  <div id="smsTemplateDiv"  style="float: left;display:none;width:47%;">
		                  		短信模板：
		                  		<select name="smsTemplate" id="smsTemplate" onchange="changeIsMessageTemplate()"  class="select_1 valid" style="visibility: visible;width:60%;">
		                  			<option value="">----请选择----</option>
		                  			<c:forEach var ="messageList" items="${messageList}">
		                  				<option value="${messageList.smsTemplateCode}">${messageList.smsTemplateName}</option>
		                  			</c:forEach>
		                  		</select>
		                  	</div>
	                  </td>
	                  	<th>是否发送注销短信：</th>
		                  <td>
		                 	  <div style="float: left;width: 18%;">
		                  		<select name="isCancelMessage" id="isCancelMessage" onchange="changeIsCancelMessage()" class="select_1 valid" style="visibility: visible;width: 95%;">
       							<option value="N">否</option>
			                  		<option value="Y">是</option>
		                  		</select>
		                  	  </div>
		                  	  <div id="cancelReceiverDiv"  style="float: left;display:none;width: 35%;">
		                  		接收人：<select name="cancelReceiver"  id="cancelReceiver" class="select_1 valid" style="visibility: visible;width: 65%;"><option value="">----请选择---</option><option value="0">投保人</option><option value="1">被保人</option></select>
		                  	  </div>
	                  	  	  <div id="cancelTemplateDiv"  style="float: left;display:none;width:47%;">
		                  		短信模板：
		                  		<select name="isCancelTemplate"  id="isCancelTemplate" onchange="changeIsCacelTemplate()" class="select_1 valid" style="visibility: visible;width:60%;">
 								    <option value="">----请选择----</option>
		                  			<c:forEach var ="cacelList" items="${cacelList}">
		                  				<option value="${cacelList.smsTemplateCode}">${cacelList.smsTemplateName}</option>
		                  			</c:forEach>
		                  		</select>
		                  	  </div>
		                  </td>			  		
			  		</tr>
			  		<tr>
						<th>是否发送电子邮件：</th>
					  		<td><select id="isEpolicyMali" onchange="CheckedSendMail()" class="select_1 valid" style="visibility: visible;"><option value="2">否</option><option value="1">是</option></select></td>	
					  		<th id="sendAccessory" >附件发送：</th>
					  		<td id="sendAccessoryTd" >
					  			<c:if test="${not empty Accessorylist}">
					  				<c:forEach items="${Accessorylist}" var="acc">
					  					<input type="checkbox" name="SendAccessoryBox" id="SendAccessoryBox"  value="${acc.code}" disabled="disabled" onchange='isSendPolicyChange(this)'> <span style="margin-left: 5px">${acc.codeName}</span>
					  				</c:forEach>
					  			</c:if>
					  			<c:if test="${not empty AccessoryEditlist}">
					  				<c:forEach items="${AccessoryEditlist}" var="acc">
					  					<input type="checkbox" name="SendAccessoryBox" id="SendAccessoryBox"  value="${acc.code}"  disabled="disabled"> <span style="margin-left: 5px">${acc.codeName}</span>
					  				</c:forEach>
					  			</c:if>
					  		</td>						  		
			  		</tr>
			  		<tr>
					<th>分公司纳税人识别号：</th>
					<td><input id="dentification" class="input_text" /></td>
					<th>是否分期：</th>
					<td>
						<div style="float: left;">
							<select name="isPayment" id="isPayment"
								onchange="choosePaymentType()" class="select_1 valid"
								style="visibility: visible;"><option value="N">否</option>
								<option value="Y">是</select>
						</div>
						<div id="isOrNotDisplayPaymentTypeDiv"
							style="float: left; display: none;">
							分期类型：<select id="paymentType" class="select_1 valid"
								style="visibility: visible; vertical-align: middle; width: 110px;">
								<c:forEach var="paymentTypeLsCode" items="${paymentTypeLs}">
									<option value="${paymentTypeLsCode.code }">${paymentTypeLsCode.codeName}</option>
								</c:forEach>
							</select>
						</div>
					</td>
				</tr>
				  <tr>
					  <th width="10%">是否增值服务:  </th>
					  <td  class="input_text" >
						  <div style="float: left;width: 190px;">
							  <select id="isAddedService" class="select_1 valid"  style="visibility: visible;width: 95%;">
								  <option value="N">否</option>
								  <option value="Y">是</option>
							  </select>
						  </div>
					  </td>
					  <th width="10%" id="addedServiceInfo1">增值服务代码:  </th>
					  <td  class="input_text" id="addedServiceInfo2">
						  <div style="float: left;width: 190px;">
							  <input id="addedServiceCode" style="float: left;width: 180px;">
						  </div>
					  </td>
				  </tr>
				  <tr id="addedServiceInfo3">
					  <th width="10%">增值服务名称:  </th>
					  <td  class="input_text" >
						  <div style="float: left;width: 190px;">
							  <input id="addedServiceName" style="float: left;width: 180px;">
						  </div>
					  </td>
					  <th width="10%">增值服务次数:  </th>
					  <td  class="input_text" >
						  <div style="float: left;width: 190px;">
							  <input id="addedServiceCount" style="float: left;width: 180px;">
						  </div>
					  </td>
				  </tr>
				  <tr>
					  <th width="10%">扫码保业务是否走重复投保校验:  </th>
					  <td  class="input_text" >
						  <div style="float: left;width: 190px;">
							  <select id="mfacadeIsReInsure" class="select_1 valid" style="visibility: visible;width: 95%;">
								  <option value="Y">是</option>
								  <option value="CY">是-仅软提示</option>
								  <option value="N">否</option>
							  </select>
						  </div>
					  </td>
					  <th width="10%" style="display: none">是否已推送销售信息:  </th>
					  <td  class="input_text" style="display: none">
						  <div style="float: left;width: 190px;">
							  <select id="isPushedSalesInfo" class="select_1 " style="background-color: #ccc;" disabled="disabled">
								  <option value="N">否</option>
								  <option value="Y">是</option>
							  </select>
						  </div>
					  </td>
				  </tr>
				  <tr>
					  <th width="10%">是否需进行风险查询：</th>
					  <td width="40">
						  <div style="float: left;width: 70px;">
							  <select id="isRiskQuery" class="select_1 valid" style="visibility: visible;width: 95%;">
								  <option value="N">否</option>
								  <option value="Y">是</option>
							  </select>
						  </div>
					  </td>
				  </tr>
					  <!-- 增加市场维护费比例、业务绩效比例文本结束 -->
				  <tr id="messageTemplateTr" style="display:none">
	                  <th>承保短信模板配置：</th>
	                  <td colspan="3"><textarea name="messageTemplate" id="messageTemplate" rows="5" class="textarea_1" style="resize:none;"></textarea><span class="red">*</span></td>
	              </tr>
	               <tr id="cancelTemplateTr" style="display:none">
	                  <th>注销短信模板配置：</th>
	                  <td colspan="3"><textarea name="cancelTemplate" id="cancelTemplate" rows="5" class="textarea_1" style="resize:none;"></textarea><span class="red">*</span></td>
	              </tr>
	              <tr id="MailTemplateTr" style="display: none;">
              	  		<th>邮件模板配置：</th>
              	  		<td colspan="3"><textarea name="MailTemplate" id="MailTemplate" rows="5" cols="" class="textarea_1" style="resize:none"></textarea><span class="red">*</span> </td>
              	  </tr>
              	  <tr>
	                  <th>审核意见：</th>
	                  <td colspan="3"><textarea name="checkOpinion" id="checkOpinion" rows="5" class="textarea_1" style="resize:none;"></textarea></td>
              	  </tr>
	              <tr>
	                  <th>特别约定：</th>
	                  <td colspan="3"><textarea name="specialArran" id="specialArran" rows="5" class="textarea_1" style="resize:none;"></textarea></td>
              	  </tr>
              	  <tr>
	                  <th>温馨提示：</th>
	                  <td colspan="3"><textarea name="notice" id="notice" cols="" rows="5" class="textarea_1" style="resize:none;"></textarea></td>
              	  </tr>
           	  </tbody>
	         </table> 
	         <div align="center">
	             <input class="input_button_4" id="saveNlifePlanBtn" type="button" onclick="CheckPassToList()" value="审核通过">&nbsp;&nbsp;
		         <input class="input_button_4" type="button"  id="saveNlifePlanBack" value="审核退回" onclick="goBackToList()">
	         </div>
	    </form>
	    
<!-- begin -------------------------产品 DIV 默认隐藏--------------------------->
  		<div id="nlifeProdDiv"  style="display:none;width:80%;">
			<div class="table_title_div">
				<table class="table_title" style='width:100%;height:20px;'>
					<tr>
					<td width="10%"></td>
					<td width="80%" id="interfaceName"></td>
					<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeNlifeProdDiv()"/></td>
					</tr>
				</table>
			</div>
	
			<table class="table_02" align="center" >
				<tr>
					<td>
						<table class="search_table">
							<tr height="30px" >
								<td style="border:0px;text-align: right;">交易系统产品代码：</td>
								<td style="border:0px;text-align: left;">
									<input name="txt3"  id="prodCode_choose" class="input_text" style="width:120px;">
								</td>
								<td style="border:0px;text-align: right;">交易系统产品名称：</td>
								<td style="border:0px;text-align: left;">
									<input name="txt3" id="prodName_choose" class="input_text" style="width:120px;">
								</td>
							</tr>
							<tr height="30px" >
								<td style="border:0px;text-align: right;">定义起期：</td>
								<td style="border:0px;text-align: left;">
									<input id="startDateBegin" onkeydown="false" onclick="showCalendar('startDateBegin','y-mm-dd');$('.calendars').css('z-index',20000);" class="input_time" type="text" style="width:120px;"/>
								</td>
								<td style="border:0px;text-align: right;">定义止期：</td>
								<td style="border:0px;text-align: left;">
								 	<input id="startDateEnd" onkeydown="false" onclick="showCalendar('startDateEnd','y-mm-dd');$('.calendars').css('z-index',20000);" class="input_time" type="text" style="width:120px;"/>
										 &nbsp;&nbsp;&nbsp;&nbsp;
									<input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryNlifeProd(1)"/>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>
						<table id="nlifeProdTable"  class="content_table_1">
							<thead>
								<tr class="f1">
				                  <th style="width:5%">选择</th>
				                  <th style="width:45%">交易系统产品代码</th>
				                  <th style="width:50%">交易系统产品描述</th>
				              	</tr>
							</thead>
							<tbody>
							</tbody>
						</table>
						<div id="nlifeProdPageDIV" class="page"></div>
					</td>
				</tr>
			</table>
			<div align="center" >
				 <input class="input_button_3" type="button" onclick="chooseNlifeProd()" value="确定">&nbsp;&nbsp;
		         <input class="input_button_3" type="button" onclick="closeNlifeProdDiv()" value="取消">
			</div>
	   </div>
<!-- end -------------------------产品 DIV 默认隐藏--------------------------->

<!-- begin --------------------------- 合作伙伴 DIV--------------------------->
  	<div id="channelInfoDiv" style="display:none;width:80%;">
  		<div class="table_title_div">
				<table class="table_title" style='width:100%;height: 20px;'>
					<tr>
					<td width="10%"></td>
					<td width="80%" id="interfaceName"></td>
					<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeChannelInfoDiv()"/></td>
					</tr>
				</table>
		</div>
		<table class="table_02" style="width:98%">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="3" style="text-align:center">
								合作伙伴代码：<input name="txt3"  id="channelCode_choose" class="input_text" />&nbsp;&nbsp;
								合作伙伴名称：<input name="txt3" id="channelName_choose" class="input_text" />&nbsp;&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryChannelInfo(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="channelInfoTable"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%">选择</th>
			                  <th style="width:10%">合作伙伴代码</th>
			                  <th style="width:20%">合作伙伴名称</th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="channelInfoPageDIV"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center">
		   <input type="button" value="确定" onclick="chooseChannelInfo()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		   <input type="button" value="取消" onclick="closeChannelInfoDiv()" class="input_button_3"/>
		</div>
	</div>	
<!-- end --------------------------- 合作伙伴 DIV--------------------------->

<!-- begin ------------------------出单机构 DIV 默认隐藏--------------------------->
	<div id="deptDiv" style="display:none;width:80%;">
		<div class="table_title_div">
			<table class="table_title" style='width:100%;height: 20px;'>
				<tr>
				<td width="10%"></td>
				<td width="80%" id="interfaceName"></td>
				<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeDeptDiv()"/></td>
				</tr>
			</table>
		</div>
		<table class="table_02" style="height:180px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="3" style="text-align:center">
							 出单机构代码：<input name="txt3"  id="deptCode_choose" class="input_text" />&nbsp;&nbsp;
							 出单机构名称：<input name="txt3" id="deptCname_choose" class="input_text" />
								       <input type="button"  class="input_button_1" value="查询" onClick="queryDept(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="deptTable"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%">选择</th>
			                  <th style="width:45%">出单机构代码</th>
			                  <th style="width:50%">出单机构名称</th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="deptPageDIV"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" value="确定" onclick="chooseDept()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeDeptDiv()" class="input_button_3"/>
		</div>
	</div>
<!-- end ------------------------出单机构 DIV 默认隐藏--------------------------->	
<!-- begin ----------------------配置个人销售业务信息 Div------------------------>
  	<div id="agentInfo3Div"  style="display:none;width:1000px; height:450px; overflow:scroll;">
		<div class="table_title_div" style="width: 1340px">
			<table class="table_title" style='width:1340px;height: 20px;'>
				<tr>
				<td width="120px"></td>
				<td width="1160px" id="interfaceName"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentInfoDiv('agentInfo3Div')"/></td>
				</tr>
			</table>
		</div>
		<table class="table_02" style="width:1340px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
							 	配置状态：<select id="confStatus_3"><option value="">全部</option><option value="Y">已配置</option><option value="N">未配置</option></select>&nbsp;&nbsp;
							 	用户名：<input id="userCode" class="input_text" />&nbsp;&nbsp;
								 姓名：<input id="userName" class="input_text" />&nbsp;&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryAgentInfo3(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentInfo3Table"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:40px"><input id="agentInfo3CheckAll" type="checkbox"></th>
			                  <th style="width:100px">用户名</th>
			                  <th style="width:100px">姓名</th>
			                  <th style="width:100px">出单机构</th>
			                  <th style="width:100px">服务代码</th>
			                  <th style="width:100px">服务名称</th>
			                  <th style="width:100px">业务员代码</th>
			                  <th style="width:100px">业务员名称</th>
			                  <th style="width:100px">单证领用人</th>
			                  <th style="width:100px">团队代码 </th>
							  <th style="width:100px">归属渠道</th>
					          <th style="width:100px">渠道类型</th>
					          <th style="width:100px">业务来源</th>
			                  <th style="width:100px">代理人编码 </th>
			                  <th style="width:100px">代理协议号</th>
			                  <th style="width:100px">手续费比例 </th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentInfo3Page" class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" value="保存" onclick="saveChosenAgentInfo3()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeAgentInfoDiv('agentInfo3Div')" class="input_button_3"/>
		</div>
	</div>
<!-- end ----------------------配置个人销售业务信息 Div------------------------>
<!-- begin ----------------------配置总对总销售业务信息 Div------------------------>
  	<div id="agentInfo4Div" style="display:none;width:1000px; height:450px; overflow:scroll;">
		<div class="table_title_div" style="width: 1440px">
			<table class="table_title" style='width:1440px;height: 20px;'>
				<tr>
				<td width="120px"></td>
				<td width="1260px" id="interfaceName"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentInfoDiv('agentInfo4Div')"/></td>
				</tr>
			</table>
		</div>
		<table class="table_02" style="width:1440px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
								配置状态：<select id="confStatus_4"><option value="">全部</option><option value="Y">已配置</option><option value="N">未配置</option></select>&nbsp;&nbsp;
							 	网点代码：<input id="branch" class="input_text" />&nbsp;&nbsp;
								网点名称：<input id="branchName" class="input_text" />&nbsp;&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryAgentInfo4(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentInfo4Table"  class="content_table_1">
						<thead>
							<tr class="f1">
			                 <th style="width:40px"><input id="agentInfo4CheckAll" type="checkbox"></th>
			                  <th style="width:100px">网点代码</th>
			                  <th style="width:100px">网点名称</th>
			                  <th style="width:80px">用户名</th>
			                  <th style="width:80px">姓名</th>
			                  <th style="width:80px">区域代码</th>
			                  <th style="width:80px">出单机构</th>
			                  <th style="width:80px">服务代码</th>
			                    <th style="width:80px">服务名称</th>
			                  <th style="width:80px">业务员代码</th>
			                   <th style="width:80px">业务员名称</th>
			                  <th style="width:80px">单证领用人 </th>
			                  <th style="width:80px">团队代码 </th>
			                  <th style="width:90px">归属渠道</th>
					          <th style="width:90px">渠道类型</th>
					          <th style="width:100px">业务来源</th>
			                  <th style="width:100px">代理人编码</th>
			                  <th style="width:100px">代理协议号</th>
			                  <th style="width:80px">手续费比例 </th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentInfo4Page"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" value="保存" onclick="saveChosenAgentInfo4()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeAgentInfoDiv('agentInfo4Div')" class="input_button_3"/>
		</div>
	</div>
<!-- end ----------------------配置总对总销售业务信息 Div------------------------>
	<!-- begin ----------------------配置联合出单销售业务信息 Div------------------------>
  	<div id="agentInfo5Div" style="display:none;width:1000px; height:450px; ">
		<div class="table_title_div" style="width: 1000px">
			<table class="table_title" style='width:1000px;height: 20px;'>
				<tr>
				<td width="120px"></td>
				<td width="1260px" id="interfaceName"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentInfoDiv('agentInfo5Div')"/></td>
				</tr>
			</table>
		</div>
		<div class="table_title_div" style="width: 1000px;height:400px; overflow:scroll;">
		<table class="table_02" style="width:1840px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
								配置状态：<select id="confStatus_5"><option value="">全部</option><option value="Y">已配置</option><option value="N">未配置</option></select>&nbsp;&nbsp;
								Key1：<input id="key1" style="width: 120px;" />&nbsp;
								Key2：<input id="key2" style="width: 120px;" />&nbsp;
								Key3：<input id="key3" style="width: 120px;" />&nbsp;
								Key4：<input id="key4" style="width: 120px;" />&nbsp;
								Key5：<input id="key5" style="width: 120px;" />&nbsp;&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryAgentInfo5(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentInfo5Table"  class="content_table_1" style=' overflow:scroll;'>
						<thead>
							<tr class="f1">
			                 <th style="width:40px"><input id="agentInfo5CheckAll" type="checkbox"></th>
			                  <th style="width:80px">出单机构</th>
			                  <th style="width:80px">服务代码</th>
			                    <th style="width:80px">服务名称</th>
			                  <th style="width:80px">业务员代码</th>
			                   <th style="width:80px">业务员名称</th>
			                  <th style="width:80px">单证领用人 </th>
			                  <th style="width:80px">团队代码 </th>
			                  <th style="width:90px">归属渠道</th>
					          <th style="width:90px">渠道类型</th>
					          <th style="width:90px">业务来源</th>
			                  <th style="width:80px">代理人编码</th>
			                  <th style="width:80px">代理协议号</th>
			                  <th style="width:80px">代理人姓名</th>
			                  <th style="width:80px">处理人</th>
			                  <th style="width:80px">Key1 </th>
			                  <th style="width:80px">Key2 </th>
			                  <th style="width:80px">Key3 </th>
			                  <th style="width:80px">Key4 </th>
			                  <th style="width:80px">Key5 </th>
			                  <th style="width:80px">手续费比例 </th>
			                  <th style="width:85px">市场维护费比例</th>
			                  <th style="width:80px">业务绩效比例 </th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentInfo5Page"  class="page"></div>
				</td>
			</tr>
		</table>
		</div>
		<div align="center" >
		  <input type="button" value="保存" onclick="saveChosenAgentInfo5()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeAgentInfoDiv('agentInfo5Div')" class="input_button_3"/>
		</div>
	</div>

<div id="unionMessageConfigDiv" style="display:none;width:80%;">
	<div class="table_title_div">
		<table class="table_title" style='width:100%;height:20px;'>
			<tr>
				<td width="10%"></td>
				<td width="80%" id="interfaceName"></td>
				<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"
												   onclick="closeUnionMessageConfigDiv(),selectUnionMessageConfigAndWriteBack()"/>
				</td>
			</tr>
		</table>
	</div>
	<table class="table_02" align="center">
		<tr>
			<td>
				<table class="search_table">
					<tr height="30px">
						<td style="border:0px;text-align: left;" id="unionMessageConfigPlanNoTitle">方案号：</td>
						<td style="border:0px;text-align: left;" id="unionMessageConfigPlanNo"></td>
						<td style="border:0px;text-align: left;" id="unionMessageConfigPlanNameTitle">方案名称：</td>
						<td style="border:0px;text-align: left;" id="unionMessageConfigPlanName"></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>适用机构：
				<select id="unionMessageConfigDept" style="margin-right: 5%" onchange="selectUnionMessageConfigAndWriteBack()">
					<c:if test="${not empty provenceDeptList}">
						<c:forEach items="${provenceDeptList}" var="provenceDept">
							<option value="${provenceDept.deptCode}">${provenceDept.deptCname}</option>
						</c:forEach>
					</c:if>
				</select>
				适用车辆座位数：
				<input id="unionMessageConfigMinSeatNum" onkeyup="clearNoNum(event,this)">
				至
				<input id="unionMessageConfigMaxSeatNum" onkeyup="clearNoNum(event,this)" style="margin-right:5%">

				方案性质：
				<select id="unionMessageConfigPlanType" onchange="selectUnionMessageConfigAndWriteBack()">
					<!-- 1意外 2健康 3财产 4责任 -->
					<option value='1'>意外险</option>
					<option value='2'>健康险</option>
					<option value='3'>财产险</option>
					<option value='4'>责任险</option>
				</select>
			</td>
		</tr>
		<tr>

			<td style="text-align: left">
				&nbsp;&nbsp;适用车辆性质：
			</td>
		</tr>
		<tr>
			<td>
				<c:if test="${not empty carNatureList}">
					<c:forEach items="${carNatureList}" var="carNature">
						<input style="margin-left: 5px" type="checkbox" name="carNatureSelector" id="carNatureSelector"
							   value="${carNature.code}" title="${carNature.code}"> ${carNature.codeName}
					</c:forEach>
				</c:if>
			</td>
		</tr>
		<tr>
			<td style="text-align: left">
				&nbsp;&nbsp;服务代码：
				<input type="text" name="carNlifeServiceCode" id="carNlifeServiceCode" style="width: 500px">
			</td>
		</tr>
		<tr>
			<td><input type="button" onclick='saveUnionMessageConfig()' value="确定"/>&nbsp&nbsp<input type="button"
																									 onclick="closeUnionMessageConfigDiv()"
																									 value="取消"></td>
		</tr>
	</table>
</div>

<!-- end ----------------------配置联合出单销售业务信息 Div------------------------>
</body>
</html>